0

我一直在尝试使此功能起作用,但它不起作用。这是我的代码和症状。

    let sPrivateKey = bitcoin.ECPair.fromWIF(private_key, TESTNET);   // sender's private key

    let tx = new bitcoin.TransactionBuilder(TESTNET);      // create new bitcoin transaction
    let txid = "e7fcaa3b0bd399e1f8ad152a984f6669d084527bbbe8267d8cb3adebbb030a38"; // hash of previous most recent transaction
    let outn = 1;
    tx.addInput(txid, outn);

    // Sending Coin
    tx.addOutput(receive address, amount To Send);
    tx.addOutput(senderWallet.publicKey, leftOver);

    try {
        await tx.sign(0, sPrivateKey);
        let txhex = tx.build().toHex();
        console.log("Transaction Hex=>>>>> " + txhex);
        return res.json({
            success: true,
            message: txhex,
            // private: sPrivateKey
        })
    } catch(err) {
        console.log("err=> " + err)
    }

上面的代码给了我这样的十六进制代码。

0200000001380a03bbebadb38c7d26e8bb7b5284d069664f982a15adf8e199d30b3baafce7000000006a47304402204a4125bce8f7fa54663f0c403059b6ef6b90864c56416dc5c680fb46a989d2bd022065d5d20221fb67916017f852cf8a39a19a57ef2b1f900cfce9ac5fa7017ecfd8012102bb2a1d80f42c16e3c2ff1eaf1979c699aae547b5cca65b8cfa1eb353d9ae0171ffffffff0240420f00000000001976a914a3277595a8a805cb5b6374fdc26f1767ec789feb88ac7c906100000000001976a9146ce96da154fc6f03656c60ae20b2663e1f488bd188ac00000000

当我在Link上检查时。我可以看到我所做的交易(将硬币发送到另一个钱包)根本不起作用。

我的问题是什么?

4

0 回答 0