• 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

json rpc – How to properly use the rpc command `listunspent` with `bitcore-lib` to create a transaction and get the transaction hash?

Moussa by Moussa
May 31, 2026
in Bitcoin
0
How do Bitcoin mining pools typically handle payout frequency versus thresholds?
189
SHARES
1.5k
VIEWS
Share on FacebookShare on Twitter


I am trying to use the rpc command listunspent to get all the UTXOs relevant to an address, and then I am trying to pass it to a transaction, using bitcore-lib.
Below is my code:

const Client = require('bitcoin-core');
const bitcore = require('bitcore-lib');
const client = new Client({ 
  network: 'regtest', 
  username: 'bitcoinuser', 
  password: 'bitcoinpass', 
  port: 18443 
});

var tx = new bitcore.Transaction();

var sourceAddress = ["mwkT2k1o6k4dF7ZZQ2VBbw7VedBkQA2CBK"];
var minconf = 6;
var maxconf = 999999;
var targetAddress = "2Mw3iwZdVXjeb7BN5hWqegFs8VdfZo5Rmdo";
var privateKey = "cQqVxdtPz95monJe8QJUE4h5JVtSSAjTQ1SU6z8PL9pmFj5V7ieA";

var txns = [];
client.listUnspent(minconf, maxconf, sourceAddress)
    .then(function(help){
    txns = help.slice();
    return txns;
  }).then(function(txns){
    return tx.from(txns).to(targetAddress, 15000).sign(privateKey);
  }).then(function(result){
    console.log(result);
  });

The result is similar to the transaction object.

What I want is to receive the transaction hash, which I can then broadcast.

Note: I am trying to run my core in regtest mode, I do not want to use livenet or testnet. I have also disclosed the public and private keys, as they do not hold any real value.

The first few lines of the output looks like this:

Transaction {
  inputs:
   [ PublicKeyInput {
       witnesses: [],
       output:
        Output {
          _satoshisBN:
           BN { negative: 0, words: [ 16972032, 37 ], length: 2, red: null 
},
          _satoshis: 2500000000,
          _scriptBuffer:
           ,
          _script:
           Script {
             chunks:
              [ { buf:
                   ,
                  len: 33,
                  opcodenum: 33 },
                { opcodenum: 172 } ],
             _isOutput: true } },
       prevTxId:
        ,
       outputIndex: 0,
       sequenceNumber: 4294967295,
       _script: Script { chunks: [], _isInput: true },
       _scriptBuffer:  },
     PublicKeyInput {
       witnesses: [],
       output:
        Output {
          _satoshisBN:



Source link

Related articles

Bitcoin Futures Hit $42.6B Across 11 Exchanges — Here Is What Open Interest Signals for June

Bitcoin Futures Hit $42.6B Across 11 Exchanges — Here Is What Open Interest Signals for June

May 31, 2026
Bitcoin News Today: Is Mining Dying as TeraWulf Abandons Miners

Bitcoin News Today: Is Mining Dying as TeraWulf Abandons Miners

May 31, 2026
Share76Tweet47

Related Posts

Bitcoin Futures Hit $42.6B Across 11 Exchanges — Here Is What Open Interest Signals for June

Bitcoin Futures Hit $42.6B Across 11 Exchanges — Here Is What Open Interest Signals for June

by Moussa
May 31, 2026
0

Key TakeawaysBitcoin futures open interest (OI) across 11 exchanges totals roughly $42.6B, with Binance (19.14%) and CME (13.88%) holding the...

Bitcoin News Today: Is Mining Dying as TeraWulf Abandons Miners

Bitcoin News Today: Is Mining Dying as TeraWulf Abandons Miners

by Moussa
May 31, 2026
0

In Bitcoin news today, TeraWulf just made the most candid statement about Bitcoin mining’s future that any publicly traded miner...

Could XRP Hit $10 This Bull Run? World’s Highest IQ Holder Thinks So

Could XRP Hit $10 This Bull Run? World’s Highest IQ Holder Thinks So

by Moussa
May 31, 2026
0

XRP investment products pulled in close to $12 million in a single day on May 29, pushing total net inflows...

British Olympian CJ Ujah Appears at Court in Crypto Fraud Case

British Olympian CJ Ujah Appears at Court in Crypto Fraud Case

by Moussa
May 31, 2026
0

Key TakeawaysOlympian CJ Ujah and 9 others faced U.K. court charges on May 28 for an organized cryptocurrency fraud scheme.The...

How do Bitcoin mining pools typically handle payout frequency versus thresholds?

lightning network – Finding paths NOT originating from you with lnd

by Moussa
May 31, 2026
0

I'm interested in finding paths from senders whose node you don't run to potential receivers. According to https://api.lightning.community/?python#queryroutes , you...

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

© 2024 APPROX FOUNDATION - The Crypto Currency News