Bitmime
You have not selected any currencies to display
  • Bitmime – Bitcoin, Ethereum, Crypto News and Market Analysis
  • Cryptocurrency
    • Crypto Mining
  • Bitcoin
  • Ethereum
  • DeFi
  • Blockchain
  • Metaverse
No Result
View All Result
  • Bitmime – Bitcoin, Ethereum, Crypto News and Market Analysis
  • Cryptocurrency
    • Crypto Mining
  • Bitcoin
  • Ethereum
  • DeFi
  • Blockchain
  • Metaverse
No Result
View All Result
Bitmime
No Result
View All Result
Home Bitcoin

script – Sending Bitcoin: Anticipated property “signature” of sort Buffer, acquired Uint8Array

Martin Spielberg by Martin Spielberg
December 25, 2024
in Bitcoin
0
script – Sending Bitcoin: Anticipated property “signature” of sort Buffer, acquired Uint8Array
189
SHARES
1.5k
VIEWS
Share on FacebookShare on Twitter


I’m attempting to ship the bitcoin with my non-public key utilizing the script and the bitcoinjs-lib. I’m continually getting the error Anticipated property "signature" of sort Buffer, acquired Uint8Array over the road once I name pstb.signInput().

I’m not ready to determine how you can resolve this,

const bitcoin = require('bitcoinjs-lib');
const ecc = require('tiny-secp256k1');
const ECPairFactory = require('ecpair').default;
const ECPair = ECPairFactory(ecc);
const { getUtxos } = require('./utxo');

const NETWORK = bitcoin.networks.bitcoin
const PRIVATE_KEY_WIF = "PRIVATE_KEY"; 
const DESTINATION_ADDRESS = "bc1q9es00454u6n49ullgg2cyh23prpglpees5ptyc"; 
const FEE = 1500; 

async perform sendBitcoin() {
    strive {
        // Import non-public key
        const keyPair = ECPair.fromWIF(PRIVATE_KEY_WIF, NETWORK);

        // Generate the tackle (Native SegWit - P2WPKH)
        const { tackle } = bitcoin.funds.p2wpkh({
            pubkey: Buffer.from(keyPair.publicKey),
            community: NETWORK,
        });
        console.log(`Sending from: ${tackle}`);

        // Fetch UTXOs for the tackle
        const utxos = await getUtxos();
        console.log(`Fetched UTXOs:`, utxos);

        if (!Array.isArray(utxos) || utxos.size === 0) {
            throw new Error("No UTXOs out there for the given tackle.");
        }

        // Create a brand new PSBT
        const psbt = new bitcoin.Psbt({ community: NETWORK });
        console.log(`Initialized PSBT:`, psbt);

        let totalInput = 0;

        // Add inputs from UTXOs
        utxos.forEach((utxo) => {
            console.log(`Including UTXO: ${JSON.stringify(utxo)}`);
            psbt.addInput({
                hash: utxo.txid,
                index: utxo.vout,
                witnessUtxo: {
                    script: Buffer.from(bitcoin.tackle.toOutputScript(tackle, NETWORK)),
                    worth: utxo.worth,
                },
            });
            totalInput += utxo.worth;
        });

        // Calculate the quantity to ship
        const sendAmount = 5000;
        if (sendAmount <= 0) {
            throw new Error("Inadequate funds after deducting charges.");
        }

        // Add output for vacation spot
        psbt.addOutput({
            tackle: DESTINATION_ADDRESS,
            worth: sendAmount,
        });

        // Add change output if relevant
        const change = totalInput - sendAmount - FEE;
        if (change > 0) {
            const changeAddress = bitcoin.funds.p2wpkh({
                pubkey: Buffer.from(keyPair.publicKey),
                community: NETWORK,
            }).tackle;
            console.log(`Including change output: ${changeAddress}`);
            psbt.addOutput({
                tackle: changeAddress,
                worth: change,
            });
        }

        utxos.forEach((_, index) => {
            console.log(`Signing enter at index: ${index}`);
            psbt.signInput(index, keyPair);
        });

        const isValid = psbt.validateSignaturesOfAllInputs();
        console.log(`Signatures legitimate: ${isValid}`);

        psbt.finalizeAllInputs();

        const rawTransaction = psbt.extractTransaction().toHex();
        console.log(`Uncooked Transaction: ${rawTransaction}`);

        console.log('Transaction able to broadcast:', rawTransaction);

        const broadcastResponse = await axios.put up('https://blockstream.data/api/tx', rawTransaction);
        console.log(`Transaction efficiently broadcasted. TXID: ${broadcastResponse.knowledge}`);
    } catch (error) {
        console.error(`Error: ${error.stack}`);
    }
}

sendBitcoin();

If required, the beneath is the package deal model listing:

{
  "dependencies": {
    "@mempool/mempool.js": "^2.3.0",
    "axios": "^1.7.9",
    "bip32": "^5.0.0-rc.0",
    "bip39": "^3.1.0",
    "bitcoinjs-lib": "^6.1.7",
    "bs58": "^6.0.0",
    "ecpair": "^3.0.0-rc.0",
    "hdkey": "^2.1.0",
    "tiny-secp256k1": "^2.2.3"
  },
  "devDependencies": {
    "dotenv": "^16.4.7"
  }
}

Related articles

Weekend Crypto Replace: $100k BTC Narrative Nonetheless Alive, Cathie Wooden & Tom Lee Affirm

Weekend Crypto Replace: $100k BTC Narrative Nonetheless Alive, Cathie Wooden & Tom Lee Affirm

November 30, 2025
Shopping for Bitcoin Will get An Improve As Apple Pay Joins The Crypto Wave

Shopping for Bitcoin Will get An Improve As Apple Pay Joins The Crypto Wave

November 30, 2025


I’m attempting to ship the bitcoin with my non-public key utilizing the script and the bitcoinjs-lib. I’m continually getting the error Anticipated property "signature" of sort Buffer, acquired Uint8Array over the road once I name pstb.signInput().

I’m not ready to determine how you can resolve this,

const bitcoin = require('bitcoinjs-lib');
const ecc = require('tiny-secp256k1');
const ECPairFactory = require('ecpair').default;
const ECPair = ECPairFactory(ecc);
const { getUtxos } = require('./utxo');

const NETWORK = bitcoin.networks.bitcoin
const PRIVATE_KEY_WIF = "PRIVATE_KEY"; 
const DESTINATION_ADDRESS = "bc1q9es00454u6n49ullgg2cyh23prpglpees5ptyc"; 
const FEE = 1500; 

async perform sendBitcoin() {
    strive {
        // Import non-public key
        const keyPair = ECPair.fromWIF(PRIVATE_KEY_WIF, NETWORK);

        // Generate the tackle (Native SegWit - P2WPKH)
        const { tackle } = bitcoin.funds.p2wpkh({
            pubkey: Buffer.from(keyPair.publicKey),
            community: NETWORK,
        });
        console.log(`Sending from: ${tackle}`);

        // Fetch UTXOs for the tackle
        const utxos = await getUtxos();
        console.log(`Fetched UTXOs:`, utxos);

        if (!Array.isArray(utxos) || utxos.size === 0) {
            throw new Error("No UTXOs out there for the given tackle.");
        }

        // Create a brand new PSBT
        const psbt = new bitcoin.Psbt({ community: NETWORK });
        console.log(`Initialized PSBT:`, psbt);

        let totalInput = 0;

        // Add inputs from UTXOs
        utxos.forEach((utxo) => {
            console.log(`Including UTXO: ${JSON.stringify(utxo)}`);
            psbt.addInput({
                hash: utxo.txid,
                index: utxo.vout,
                witnessUtxo: {
                    script: Buffer.from(bitcoin.tackle.toOutputScript(tackle, NETWORK)),
                    worth: utxo.worth,
                },
            });
            totalInput += utxo.worth;
        });

        // Calculate the quantity to ship
        const sendAmount = 5000;
        if (sendAmount <= 0) {
            throw new Error("Inadequate funds after deducting charges.");
        }

        // Add output for vacation spot
        psbt.addOutput({
            tackle: DESTINATION_ADDRESS,
            worth: sendAmount,
        });

        // Add change output if relevant
        const change = totalInput - sendAmount - FEE;
        if (change > 0) {
            const changeAddress = bitcoin.funds.p2wpkh({
                pubkey: Buffer.from(keyPair.publicKey),
                community: NETWORK,
            }).tackle;
            console.log(`Including change output: ${changeAddress}`);
            psbt.addOutput({
                tackle: changeAddress,
                worth: change,
            });
        }

        utxos.forEach((_, index) => {
            console.log(`Signing enter at index: ${index}`);
            psbt.signInput(index, keyPair);
        });

        const isValid = psbt.validateSignaturesOfAllInputs();
        console.log(`Signatures legitimate: ${isValid}`);

        psbt.finalizeAllInputs();

        const rawTransaction = psbt.extractTransaction().toHex();
        console.log(`Uncooked Transaction: ${rawTransaction}`);

        console.log('Transaction able to broadcast:', rawTransaction);

        const broadcastResponse = await axios.put up('https://blockstream.data/api/tx', rawTransaction);
        console.log(`Transaction efficiently broadcasted. TXID: ${broadcastResponse.knowledge}`);
    } catch (error) {
        console.error(`Error: ${error.stack}`);
    }
}

sendBitcoin();

If required, the beneath is the package deal model listing:

{
  "dependencies": {
    "@mempool/mempool.js": "^2.3.0",
    "axios": "^1.7.9",
    "bip32": "^5.0.0-rc.0",
    "bip39": "^3.1.0",
    "bitcoinjs-lib": "^6.1.7",
    "bs58": "^6.0.0",
    "ecpair": "^3.0.0-rc.0",
    "hdkey": "^2.1.0",
    "tiny-secp256k1": "^2.2.3"
  },
  "devDependencies": {
    "dotenv": "^16.4.7"
  }
}

Tags: BitcoinBufferExpectedpropertyscriptSendingsignatureTypeUint8Array
Share76Tweet47

Related Posts

Weekend Crypto Replace: $100k BTC Narrative Nonetheless Alive, Cathie Wooden & Tom Lee Affirm

Weekend Crypto Replace: $100k BTC Narrative Nonetheless Alive, Cathie Wooden & Tom Lee Affirm

by Martin Spielberg
November 30, 2025
0

It’s the weekend once more, and in as we speak’s crypto replace, the broader market stays oversold with the Worry...

Shopping for Bitcoin Will get An Improve As Apple Pay Joins The Crypto Wave

Shopping for Bitcoin Will get An Improve As Apple Pay Joins The Crypto Wave

by Martin Spielberg
November 30, 2025
0

Trusted Editorial content material, reviewed by main business specialists and seasoned editors. Advert Disclosure The pathway to buying Bitcoin and...

Bitcoin Value Stays Above $90K — How Lengthy Can It Maintain On?

Bitcoin Value Stays Above $90K — How Lengthy Can It Maintain On?

by Martin Spielberg
November 29, 2025
0

Over the previous week, the Bitcoin worth had its greatest efficiency for the reason that notorious October 10 downturn, which...

DMND Pool Now Open To All Miners, With SOC 2 Compliance And Stratum V2 Assist

DMND Pool Now Open To All Miners, With SOC 2 Compliance And Stratum V2 Assist

by Martin Spielberg
November 29, 2025
0

DMND, a brand new mining pool constructed round Stratum V2 which started taking candidates for a gentle personal launch earlier...

Steerage for newbie making an attempt to fetch information on Blockchain

Steerage for newbie making an attempt to fetch information on Blockchain

by Martin Spielberg
November 28, 2025
0

I'd actually recognize your skilled's steering on just a little mission I want to get going. The concept could be...

Load More
  • Trending
  • Comments
  • Latest
Alchemy Quietly Buys NFT Launchpad HeyMint – Right here’s Extra data

Alchemy Quietly Buys NFT Launchpad HeyMint – Right here’s Extra data

May 25, 2025
BitHub 77-Bit token airdrop information

BitHub 77-Bit token airdrop information

January 15, 2025
Volatility Shares debuts first 1x XRP futures ETF for US buyers

Volatility Shares debuts first 1x XRP futures ETF for US buyers

May 26, 2025
Texas football’s rivalry matchup with Texas A&M

Texas football’s rivalry matchup with Texas A&M

May 9, 2025
6 Methods Web3 Is Altering On-line Communities

6 Methods Web3 Is Altering On-line Communities

1
Dogecoin (DOGE) Eyes $0.50 Once more: Is a New Rally on the Horizon?

Dogecoin (DOGE) Eyes $0.50 Once more: Is a New Rally on the Horizon?

0
Binance Pool Introduces Merged Mining with Fractal Bitcoin (FB) Rewards

Binance Pool Introduces Merged Mining with Fractal Bitcoin (FB) Rewards

0
Are Retail Buyers Behind The Bitcoin Worth Surge This Bull Run?

Are Retail Buyers Behind The Bitcoin Worth Surge This Bull Run?

0
ESPORTS is offered for buying and selling!

ESPORTS is offered for buying and selling!

November 30, 2025
BNB Chain Strengthens Management with Nina Rong as Government Director of Progress

BNB Chain Strengthens Management with Nina Rong as Government Director of Progress

November 30, 2025
Weekend Crypto Replace: $100k BTC Narrative Nonetheless Alive, Cathie Wooden & Tom Lee Affirm

Weekend Crypto Replace: $100k BTC Narrative Nonetheless Alive, Cathie Wooden & Tom Lee Affirm

November 30, 2025
Crypto Holders Warned as UK Finances Confirms Platforms Will Observe Features

Crypto Holders Warned as UK Finances Confirms Platforms Will Observe Features

November 30, 2025

About Us

Welcome to Bitmime.com, your go-to destination for the latest and most reliable news from the world of cryptocurrency, blockchain, and decentralized finance.

Categories

  • Bitcoin
  • Blockchain
  • Crypto Mining
  • Cryptocurrency
  • DeFi
  • Ethereum
  • Metaverse
  • Uncategorized

Recent Posts

  • ESPORTS is offered for buying and selling!
  • BNB Chain Strengthens Management with Nina Rong as Government Director of Progress
  • Weekend Crypto Replace: $100k BTC Narrative Nonetheless Alive, Cathie Wooden & Tom Lee Affirm
  • Bitmime – Bitcoin, Ethereum, Crypto News and Market Analysis
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions

© 2024 bitmime.com. All rights reserved.

No Result
View All Result
  • Bitmime – Bitcoin, Ethereum, Crypto News and Market Analysis
  • Cryptocurrency
    • Crypto Mining
  • Bitcoin
  • Ethereum
  • DeFi
  • Blockchain
  • Metaverse

© 2024 bitmime.com. All rights reserved.