Earn 3,600 ($36.00)
Bitcoin Javascript Gist - PSBT
Bounty Description
Deliverable
A single javascript file that contains:
-
Generate three wallets, and three public keys. Wallet named: Alice, Bob, Charlie.
-
Alice to generate a UTXO that contains 546 satoshis. You can use OP_DATA to write "hello".
-
A PSBT is created with Alice to sign Input 1, which contains UTXO in (2). Alice then add Output 1, which is a P2SH to her public key for the amount 0.01 BTC. Add ANYONECANPAY flag.
-
Encode (3) into hexstring, and then decoded back into PSBT.
-
Based on (3), Charlie adds Output 2, which is his P2SH to his public key for the amount of 10000 satoshis.
-
Based on (4), Bob who wants to buy, adds Input 2, which is his last UTXO P2SH, contraining 0.012 BTC. Bob also add Output 3, which is his P2SH to his public key for the amount of 10000 satoshis. Bob then signs Input 2.
7.Encode (6), all inputs signed, into hexstring, and then decoded back into PSBT.
- Bob then broadcast the signed PSBT in (7).
Requirements
- Use @scure libraries including bip32, bip39 to generate keys and btc-signer to construct the transaction and sign the transaction.
https://github.com/paulmillr/scure-btc-signer
https://github.com/paulmillr/scure-bip32
https://github.com/paulmillr/scure-bip39
- The code can work on Bitcoin mainnet, test network, and regtest. Since the amount is huge on mainchain, we are going to test it on regtest, but i will change the value and see whether it will work on mainchain.