• About
  • FAQ
  • Earn Bitcoin while Surfing the net
  • Buy & Sell Crypto on Paxful
Newsletter
Approx Foundation
  • Home
    • Home – Layout 1
  • Bitcoin
  • Ethereum
  • Regulation
  • Market
  • Blockchain
  • Business
  • Guide
  • Contact Us
No Result
View All Result
  • Home
    • Home – Layout 1
  • Bitcoin
  • Ethereum
  • Regulation
  • Market
  • Blockchain
  • Business
  • Guide
  • Contact Us
No Result
View All Result
Approx Foundation
No Result
View All Result
Home Bitcoin

bitcoin core – Error in sending transaction:Insufficient funds

Moussa by Moussa
February 18, 2025
in Bitcoin
0
peer discovery – how to obtain the IP addresses of nodes for mining pools?
189
SHARES
1.5k
VIEWS
Share on FacebookShare on Twitter


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

async function setTransactionFee() {
  try {
    const success = await client.setTxFee(0.00001);
    console.log("Transaction fee rate set to 21 sats/vB");
  } catch (error) {
    console.log("Error setting fee rate:", error);
  }
}
async function main() {
  // await client.loadWallet("testwallet");
  try {
    const address = await client.getNewAddress();
    console.log("Address:", address);
    await client.generateToAddress(103, address);
    const balance = await client.getBalance();
    console.log(balance);
    const txid1 = await client.sendToAddress(SENDER_ADDRESS, 100);
    console.log("Sent 100 BTC, TXID:", txid1);

    // 6. Get raw transaction details
    const txDetails = await client.getRawTransaction(txid1, true);

    // 7. Construct Raw Transaction
    const rawTx = await client.createRawTransaction(
      [
        {
          txid: txid1,
          vout: 0,
        },
      ],
      {
        bcrt1qq2yshcmzdlznnpxx258xswqlmqcxjs4dssfxt2: 100,
        data: Buffer.from("We are all Satoshi!!", "utf8").toString("hex"),
      }
    );

    // 8. Fund the raw transaction with required fee rate
    const fundedTx = await client.fundRawTransaction(rawTx, { fee_rate: 21 });
    console.log("Funded TX:", fundedTx);

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

    // 10. Broadcast the transaction
    const finalTxid = await client.sendRawTransaction(signedTx.hex);
    console.log("Final 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);
  }
}
try {
  main();
} catch (e) {
  console.log("Error:", e);
}

I am trying to run this transaction
but getting the following error

Address: bcrt1q930lz38fuqaw83ujh8s050yyntaev2ll6xrzvu
11649.99941734
Sent 100 BTC, TXID: d6f19c05ec6f5022907b38c521ac387d8c3186f30ecef81d2bd1a40703d52eed
Error: RpcError: Insufficient funds

I have enough balance as u can see what am i doing wrong here?



Source link

Related articles

BNY Brings 24/7 Dollar Settlement to Singapore Gulf Bank

BNY Brings 24/7 Dollar Settlement to Singapore Gulf Bank

October 13, 2026
Congressman Keith Self Moves To Block US CBDC Via Defense Bill Amendment

AI Predicts SUI as Sui Buys a Whole Blockchain for $30M

October 13, 2026
Share76Tweet47

Related Posts

BNY Brings 24/7 Dollar Settlement to Singapore Gulf Bank

BNY Brings 24/7 Dollar Settlement to Singapore Gulf Bank

by Moussa
October 13, 2026
0

Key TakeawaysSingapore Gulf Bank adopted BNY’s 24/7 USD settlement for eligible weekend and holiday payments.The move narrows stablecoins’ always-on edge...

Congressman Keith Self Moves To Block US CBDC Via Defense Bill Amendment

AI Predicts SUI as Sui Buys a Whole Blockchain for $30M

by Moussa
October 13, 2026
0

The Sui Foundation has paid $30 million to bring an entire blockchain onto its network, and the market answered by...

The Amount Of Bitcoin On Exchanges Is Shrinking

The Amount Of Bitcoin On Exchanges Is Shrinking

by Moussa
October 13, 2026
0

Bitcoin’s price could be due a move upwards as the supply of the leading cryptocurrency on exchanges shrinks.  That’s according...

Interactive Brokers Rolls out Ether Staking With Zerohash – Bitcoin News

Interactive Brokers Rolls out Ether Staking With Zerohash – Bitcoin News

by Moussa
October 13, 2026
0

Key TakeawaysInteractive Brokers is taking another step into crypto, teaming up with Zerohash to let eligible clients stake ether and...

Aptos Makes Encrypted Mempool Optional on Mainnet

by Moussa
October 13, 2026
0

Aptos crypto has activated its optional Encrypted Mempool on mainnet, letting compatible wallets and apps conceal pending transaction instructions, assets...

Load More

youssufi.com

sephina.com

[vc_row full_width="stretch_row" parallax="content-moving" vc_row_background="" background_repeat="no-repeat" background_position="center center" footer_scheme="dark" css=".vc_custom_1517813231908{padding-top: 60px !important;padding-bottom: 30px !important;background-color: #191818 !important;background-position: center;background-repeat: no-repeat !important;background-size: cover !important;}" footer_widget_title_color="#fcbf46" footer_button_bg="#fcb11e"][vc_column width="1/4"]

We bring you the latest in Crypto News

[/vc_column][vc_column width="1/4"][vc_wp_categories]
[/vc_column][vc_column width="1/4"][vc_wp_tagcloud taxonomy="post_tag"][/vc_column][vc_column width="1/4"]

Newsletter

[vc_raw_html]JTNDcCUzRSUzQ2RpdiUyMGNsYXNzJTNEJTIydG5wJTIwdG5wLXN1YnNjcmlwdGlvbiUyMiUzRSUwQSUzQ2Zvcm0lMjBtZXRob2QlM0QlMjJwb3N0JTIyJTIwYWN0aW9uJTNEJTIyaHR0cHMlM0ElMkYlMkZhcHByb3gub3JnJTJGJTNGbmElM0RzJTIyJTNFJTBBJTBBJTNDaW5wdXQlMjB0eXBlJTNEJTIyaGlkZGVuJTIyJTIwbmFtZSUzRCUyMm5sYW5nJTIyJTIwdmFsdWUlM0QlMjIlMjIlM0UlM0NkaXYlMjBjbGFzcyUzRCUyMnRucC1maWVsZCUyMHRucC1maWVsZC1maXJzdG5hbWUlMjIlM0UlM0NsYWJlbCUyMGZvciUzRCUyMnRucC0xJTIyJTNFRmlyc3QlMjBuYW1lJTIwb3IlMjBmdWxsJTIwbmFtZSUzQyUyRmxhYmVsJTNFJTBBJTNDaW5wdXQlMjBjbGFzcyUzRCUyMnRucC1uYW1lJTIyJTIwdHlwZSUzRCUyMnRleHQlMjIlMjBuYW1lJTNEJTIybm4lMjIlMjBp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
  • Business
  • Guide

© 2024 APPROX FOUNDATION - The Crypto Currency News