A simple Node.js script for Bitcoin script construction, address derivation, and transaction building.
This project provides a set of Node.js functions to perform various Bitcoin-related tasks, including:
- Generating a redeem script in hex format.
- Deriving a Bitcoin address from a redeem script.
- Constructing a transaction that sends Bitcoins to a specified address.
- Constructing another transaction that spends from the previous transaction, considering both locking and unlocking scripts.
- Node.js installed
Clone the repository: git clone https://github.com/fahadkabali/transactionBuilder.git
Change into the project directory: cd bitcoin-script-builder Install dependencies: npm install
Example script usage: node transactionBuilder.js Replace placeholder values in the script with your actual transaction details.
function generateRedeemScript(preImage): Generates a redeem script in hex format using a provided pre-image. function deriveAddress(redeemScript): Derives a Bitcoin address from a redeem script. function constructTransaction(address, amount): Constructs a transaction that sends Bitcoins to the specified address. function constructSpendingTransaction(previousTxHex, unlockingScript, outputAddress, outputAmount): Constructs a transaction that spends from the previous transaction, considering locking and unlocking scripts.
To run tests, use the following command: npm test Ensure that you have updated the test cases according to your specific functions.