dart-bitcoin / bitcoin_flutter

A dart Bitcoin library for Flutter.
MIT License
165 stars 123 forks source link

Transaction is not broadcasting to the blockchain network #62

Closed mrgulshanyadav closed 3 years ago

mrgulshanyadav commented 3 years ago

After signing the transaction and calling the build function on TransactionBuilder. It is not broadcasting to the blockchain network. How to solve this? Please help. Do I need to perform any extra steps for broadcast?

NetworkType versacoin = new NetworkType(
    messagePrefix: '\x19VersaCoin Signed Message:\n',
    bech32: 'go',
    bip32: new Bip32Type(public: 0x0488B21E, private: 0x0488ADE4),
    pubKeyHash: 0x46, // 70 in decimal, V in prefix symbol
    scriptHash: 0x05, // 5 in decimal, 3 in prefix symbol
    wif: 0xc6, // 198 in decimal, 2 in prefix symbol
);

final alice = ECPair.fromWIF(privateKey, network: versacoin);
final txb = new TransactionBuilder(network: versacoin);

final p2wpkh = new P2WPKH(data: new PaymentData(pubkey: alice.publicKey), network: versacoin).data;

txb.addInput(versaCoinGetAddressResponse.lastTxs[i].addresses, 0, null, p2wpkh.output);
txb.addOutput(toAddress, 1000000);

txb.sign(vin: 0, keyPair: alice, witnessValue:  2500);

// prepare for broadcast to the Bitcoin network, see 'can broadcast a Transaction' below
String txHash = txb.build().toHex();
p3root commented 3 years ago

You need to broadcast it to the node yourself! The library only builds and signes the transactions.