Bitcoin Forum
May 17, 2024, 05:41:25 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: Calculate how many BTC an address own from RPC calls  (Read 349 times)
TheWolf666 (OP)
Full Member
***
Offline Offline

Activity: 615
Merit: 154


CEO of Metaisland.gg and W.O.K Corp


View Profile WWW
February 06, 2021, 10:07:59 AM
 #21

It seems that there is a problem specific to windows.

For example

This is working on Unix
Code:
./bitcoin-cli scantxoutset start  '["addr(1CUTyyxgbKvtCdoYmceQJCZLXCde5akiX2)"]'

But this is not on windows

Code:
bitcoin-cli.exe scantxoutset start  '["addr(1CUTyyxgbKvtCdoYmceQJCZLXCde5akiX2)"]'

error: Error parsing JSON:'[addr(1CUTyyxgbKvtCdoYmceQJCZLXCde5akiX2)]'

Escaping like this bitcoin-cli.exe scantxoutset start  '[\"addr(1CUTyyxgbKvtCdoYmceQJCZLXCde5akiX2)\"]'
does not change anything, it fails.

Any clue?

HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
February 06, 2021, 11:34:02 AM
 #22

It'll be the way that the Windows "shell" is interpreting the characters... are you using cmd.exe/"command prompt" or powershell? Huh

The format for using scantxoutset on the Windows command prompt seems to be:
Code:
bitcoin-cli.exe scantxoutset start [\"addr(1CUTyyxgbKvtCdoYmceQJCZLXCde5akiX2)\"]

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
TheWolf666 (OP)
Full Member
***
Offline Offline

Activity: 615
Merit: 154


CEO of Metaisland.gg and W.O.K Corp


View Profile WWW
February 07, 2021, 06:57:53 AM
 #23

It'll be the way that the Windows "shell" is interpreting the characters... are you using cmd.exe/"command prompt" or powershell? Huh

The format for using scantxoutset on the Windows command prompt seems to be:
Code:
bitcoin-cli.exe scantxoutset start [\"addr(1CUTyyxgbKvtCdoYmceQJCZLXCde5akiX2)\"]

Actually you are right, it is working, I am using cmd because I call it from PHP and that's what it does.,
Here is the solution:

From the command prompt, no " or ' are accepted.

Code:
bitcoin-cli.exe scantxoutset start [\"addr(1CUTyyxgbKvtCdoYmceQJCZLXCde5akiX2)\"]

From PHP retval is an array with the response and $r is the return code true or false

Code:
$address="1CUTyyxgbKvtCdoYmceQJCZLXCde5akiX2";
$s='bitcoin-cli.exe scantxoutset start [\"addr('.$address.')\"] ';
exec($s,$retval,$r);

This solution is working but it sucks because it is really slow compared to RPC.
I could not get a positive result with any JSON formatted submission to RPC.  Kiss Cry

NotATether
Legendary
*
Offline Offline

Activity: 1610
Merit: 6746


bitcoincleanup.com / bitmixlist.org


View Profile WWW
February 07, 2021, 07:44:49 AM
 #24

It seems that there is a problem specific to windows.

...

But this is not on windows

Code:
bitcoin-cli.exe scantxoutset start  '["addr(1CUTyyxgbKvtCdoYmceQJCZLXCde5akiX2)"]'

error: Error parsing JSON:'[addr(1CUTyyxgbKvtCdoYmceQJCZLXCde5akiX2)]'


In Windows' command prompt, the left and right parentheses are considered special characters and have to be escaped with a ^ character, not a backslash. They are not special in Linux which is why it works there. So try escaping those in your RPC call and try it again.

The Windows command-line interpreter uses a caret character (^) to escape reserved characters that have special meanings (in particular: &, |, (, ), <, >, ^).[4] The DOS command-line interpreter, though it has similar syntax, does not support this.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: « 1 [2]  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!