bitcoin core – Error in sending transaction:Inadequate funds

0
30
bitcoin core – Error in sending transaction:Inadequate funds


import Shopper from "bitcoin-core";
import fs from "fs";
const shopper = new Shopper({
  community: "regtest",
  username: "alice",
  password: "password",
  host: "http://alice:password@localhost:18443",
});
const SENDER_ADDRESS = "bcrt1qq2yshcmzdlznnpxx258xswqlmqcxjs4dssfxt2";

async perform setTransactionFee() {
  strive {
    const success = await shopper.setTxFee(0.00001);
    console.log("Transaction payment charge set to 21 sats/vB");
  } catch (error) {
    console.log("Error setting payment charge:", error);
  }
}
async perform essential() {
  // await shopper.loadWallet("testwallet");
  strive {
    const deal with = await shopper.getNewAddress();
    console.log("Deal with:", deal with);
    await shopper.generateToAddress(103, deal with);
    const steadiness = await shopper.getBalance();
    console.log(steadiness);
    const txid1 = await shopper.sendToAddress(SENDER_ADDRESS, 100);
    console.log("Despatched 100 BTC, TXID:", txid1);

    // 6. Get uncooked transaction particulars
    const txDetails = await shopper.getRawTransaction(txid1, true);

    // 7. Assemble Uncooked Transaction
    const rawTx = await shopper.createRawTransaction(
      [
        {
          txid: txid1,
          vout: 0,
        },
      ],
      {
        bcrt1qq2yshcmzdlznnpxx258xswqlmqcxjs4dssfxt2: 100,
        knowledge: Buffer.from("We're all Satoshi!!", "utf8").toString("hex"),
      }
    );

    // 8. Fund the uncooked transaction with required payment charge
    const fundedTx = await shopper.fundRawTransaction(rawTx, { fee_rate: 21 });
    console.log("Funded TX:", fundedTx);

    // 9. Signal the transaction
    const signedTx = await shopper.signRawTransactionWithWallet(fundedTx.hex);
    console.log("Signed TX:", signedTx);

    // 10. Broadcast the transaction
    const finalTxid = await shopper.sendRawTransaction(signedTx.hex);
    console.log("Ultimate Transaction ID:", finalTxid);

    // 11. Write TXID to a file
    fs.writeFileSync("../out.txt", finalTxid);
    console.log("Transaction ID written to out.txt");
  } catch (err) {
    console.error("Error:", err);
  }
}
strive {
  essential();
} catch (e) {
  console.log("Error:", e);
}

I’m attempting to run this transaction
however getting the next error

Deal with: bcrt1q930lz38fuqaw83ujh8s050yyntaev2ll6xrzvu
11649.99941734
Despatched 100 BTC, TXID: d6f19c05ec6f5022907b38c521ac387d8c3186f30ecef81d2bd1a40703d52eed
Error: RpcError: Inadequate funds

I’ve sufficient steadiness as u can see what am i doing flawed right here?

LEAVE A REPLY

Please enter your comment!
Please enter your name here