Author

Topic: scantxoutset example (Read 188 times)

legendary
Activity: 1512
Merit: 7340
Farewell, Leo
December 26, 2023, 10:44:31 AM
#11
Thanks. Code work ok then. It just a problem with this particular address. A lot needed to know about bitcoin internals. I'm heard first time about '50 non-spendable bitcoins of the genesis block'.
Oh, yeah. It is mainly encyclopedic knowledge, but it might seem strange to anyone programming Bitcoin. For some reason, Satoshi decided to not include the coinbase transaction to the global transaction database (you can confirm this by getrawtransaction). Maybe he did to not be called a preminer as genesis block was mined before he released the very first Bitcoin client binaries.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
December 26, 2023, 05:57:49 AM
#10
No need to rely on any third party blockchain explorers.  Way better privacy!

Yeh. But it very slow to query this rpc call to local bitcoin core. Is any way to improve bitcoin core response time for this type of query? Thanks.

You either must,
1. Add that address to wallet so it'll be indexed by Bitcoin Core. First rescan is slow, but afterwards you only need to use wallet RPC call.
2. Run either self-hosted Electrum server or block-explorer which index all Bitcoin address.
newbie
Activity: 37
Merit: 0
December 25, 2023, 08:38:27 AM
#9
No need to rely on any third party blockchain explorers.  Way better privacy!

Yeh. But it very slow to query this rpc call to local bitcoin core. Is any way to improve bitcoin core response time for this type of query? Thanks.
member
Activity: 104
Merit: 120
December 22, 2023, 05:47:41 PM
#8
I believe the command syntax you're looking for would be this:

scantxoutset start "[\"addr(PasteYourAddressHere)\"]"

No need to rely on any third party blockchain explorers.  Way better privacy!
newbie
Activity: 37
Merit: 0
December 22, 2023, 04:38:04 PM
#7
I have following RPC code. It runs on local fully synced bitcoin core node.
You'll have to be a little more explanatory. Where is this code from? Is it yours? What's the library you're using? Judging by the fact that it's C#, may I suppose it's NBitcoin?

For example for address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa it returns 22.73242908 BTC, instead of correct 72.74245948 BTC.
That particular address is the exception to the rule, because it was rewarded with the 50 non-spendable bitcoins of the genesis block. The correct amount of spendable coins is 22.73242908.

Judging by the code, it gets the total balance by summing the UTXOs. Since the block reward of genesis isn't UTXO, it doesn't count it.

Thanks. Code work ok then. It just a problem with this particular address. A lot needed to know about bitcoin internals. I'm heard first time about '50 non-spendable bitcoins of the genesis block'.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
December 22, 2023, 04:24:45 PM
#6
I have following RPC code. It runs on local fully synced bitcoin core node.
You'll have to be a little more explanatory. Where is this code from? Is it yours? What's the library you're using? Judging by the fact that it's C#, may I suppose it's NBitcoin?

For example for address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa it returns 22.73242908 BTC, instead of correct 72.74245948 BTC.
That particular address is the exception to the rule, because it was rewarded with the 50 non-spendable bitcoins of the genesis block. The correct amount of spendable coins is 22.73242908.

Judging by the code, it gets the total balance by summing the UTXOs. Since the block reward of genesis isn't UTXO, it doesn't count it.
newbie
Activity: 37
Merit: 0
December 22, 2023, 04:06:37 PM
#5
Hello.

I have following RPC code. It runs on local fully synced bitcoin core node.

JObject getAddressUtxosResponse = rpcClient.InvokeMethod("scantxoutset", "start", new[] { $"addr({bitcoinAddress})" });
JValue success = (JValue)getAddressUtxosResponse["result"]["success"];
if ((bool)success == true)
{
    // get total balance by total_amount
    JValue total_amount = (JValue)getAddressUtxosResponse["result"]["total_amount"];
    decimal totalBalance = (decimal)total_amount;
}

It return incorrect amount.
For example for address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa it returns 22.73242908 BTC, instead of correct 72.74245948 BTC.
Why this is can happen?
Thanks.
legendary
Activity: 2394
Merit: 5531
Self-proclaimed Genius
October 25, 2023, 12:36:02 AM
#4
Also note that in addition to the descriptor itself, you will usually have to pass the checksum of the descriptor right after it - the hash '#' followed by a bunch of letters and numbers.
That's only mandatory in importdescriptors command.
But scantxoutset will work regardless of the presence or absence of the checksum as of v25.0


Anyways, OP was asking for the "syntax" so most likely, he knows what arguments to include, just how to put them together which he already did in the edit.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
October 24, 2023, 08:49:47 AM
#3
Also note that in addition to the descriptor itself, you will usually have to pass the checksum of the descriptor right after it - the hash '#' followed by a bunch of letters and numbers. There are some software that can calculate this for you, but it's much easier to use getdescriptorinfo and pass the descriptor without checksum, in order to fetch it.

Example can be found here: https://developer.bitcoin.org/reference/rpc/getdescriptorinfo.html
legendary
Activity: 1260
Merit: 1954
October 23, 2023, 04:39:55 AM
#2
It looks like you already found the way how to scan the outputs for a specific address.

Besides that you can also use
Code:
scantxoutset start '["raw(hex_script)"]
if you want to scan specific hex scripts.

or

Code:
scantxoutset start '["pkh(pubkey)"]
to scan P2PKH outputs of the public key you are interested in.
full member
Activity: 161
Merit: 168
October 22, 2023, 09:46:26 PM
#1
please delete!
Jump to: