• 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

CoinRabbit Hits Six Years of Incident-Free Custody With ChangeNOW’s NOWCustody

CoinRabbit Hits Six Years of Incident-Free Custody With ChangeNOW’s NOWCustody

August 28, 2026
Congressman Keith Self Moves To Block US CBDC Via Defense Bill Amendment

Goldman Sachs Crypto: Bank Raises Coinbase Target Despite Crypto Volume Slump

August 28, 2026
Share76Tweet47

Related Posts

CoinRabbit Hits Six Years of Incident-Free Custody With ChangeNOW’s NOWCustody

CoinRabbit Hits Six Years of Incident-Free Custody With ChangeNOW’s NOWCustody

by Moussa
August 28, 2026
0

CoinRabbit, a crypto asset management platform, has passed six years with no security incident and no loss of client assets,...

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

Goldman Sachs Crypto: Bank Raises Coinbase Target Despite Crypto Volume Slump

by Moussa
August 28, 2026
0

In Goldman Sachs crypto news, the financial institution maintained buy ratings on Coinbase Global and Robinhood Markets on August 25,...

Dunamu Partners With Visa to Build Stablecoin, AI Payment Rails

Dunamu Partners With Visa to Build Stablecoin, AI Payment Rails

by Moussa
August 28, 2026
0

Key TakeawaysDunamu and Visa signed a stablecoin and AI payments partnership on Aug. 27 in San Francisco.The deal explores Open...

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

Why Warsh’s First Jackson Hole Speech Could Decide the Next Bitcoin Move

by Moussa
August 28, 2026
0

In Bitcoin news today, BTC has climbed from roughly $64,000 to $80,000 in a single week, and the next major...

Pakistan Built Its Crypto Regulatory Regime Using Just 8% Of Its Budget, Minister Bilal Bin Saqib Reveals At Bitcoin Asia

Pakistan Built Its Crypto Regulatory Regime Using Just 8% Of Its Budget, Minister Bilal Bin Saqib Reveals At Bitcoin Asia

by Moussa
August 28, 2026
0

Pakistan has launched its virtual asset regulatory regime in less than six months while using just 8% of the budget...

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]JTNDcCUzRSUzQ2RpdiUyMGNsYXNzJTNEJTIydG5wJTIwdG5wLXN1YnNjcmlwdGlvbiUyMiUzRSUwQSUzQ2Zvcm0lMjBtZXRob2QlM0QlMjJwb3N0JTIyJTIwYWN0aW9uJTNEJTIyaHR0cHMlM0ElMkYlMkZhcHByb3gub3JnJTJGJTNGbmElM0RzJTIyJTNFJTBBJTBBJTNDaW5wdXQlMjB0eXBlJTNEJTIyaGlkZGVuJTIyJTIwbmFtZSUzRCUyMm5sYW5nJTIyJTIwdmFsdWUlM0QlMjIlMjIlM0UlM0NkaXYlMjBjbGFzcyUzRCUyMnRucC1maWVsZCUyMHRucC1maWVsZC1maXJzdG5hbWUlMjIlM0UlM0NsYWJlbCUyMGZvciUzRCUyMnRucC0xJTIyJTNFRmlyc3QlMjBuYW1lJTIwb3IlMj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SUwQSUzQyUyRmRpdiUzRSUwQSUzQyUyRmZvcm0lM0UlMEElM0MlMkZkaXYlM0UlM0NiciUyRiUzRSUzQyUyRnAlM0U=[/vc_raw_html][/vc_column][/vc_row]
No Result
View All Result
  • Contact Us
  • Homepages
  • Business
  • Guide

© 2024 APPROX FOUNDATION - The Crypto Currency News