Bitcoin Forum
May 01, 2024, 04:50:24 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: getaddressbalance is not accurate ?  (Read 124 times)
johnal (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
October 28, 2023, 09:38:20 AM
 #1

getaddressbalance is not accurate:

Code:
$ ./electrum-4.4.6/run_electrum  getaddressbalance 18jANvQ6AuVGJnea4EhmXiAf6bHR5qKjPB
{
    "confirmed": "0.00099822",
    "unconfirmed": "0"
}

But real balance is 30.99099822 BTC

see https://blockchair.com/bitcoin/address/18jANvQ6AuVGJnea4EhmXiAf6bHR5qKjPB
and
https://blockchain.info/balance?active=18jANvQ6AuVGJnea4EhmXiAf6bHR5qKjPB

What can be wrong? The servers I'm relying on?
1714582224
Hero Member
*
Offline Offline

Posts: 1714582224

View Profile Personal Message (Offline)

Ignore
1714582224
Reply with quote  #2

1714582224
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714582224
Hero Member
*
Offline Offline

Posts: 1714582224

View Profile Personal Message (Offline)

Ignore
1714582224
Reply with quote  #2

1714582224
Report to moderator
1714582224
Hero Member
*
Offline Offline

Posts: 1714582224

View Profile Personal Message (Offline)

Ignore
1714582224
Reply with quote  #2

1714582224
Report to moderator
hosseinimr93
Legendary
*
Offline Offline

Activity: 2380
Merit: 5235



View Profile
October 28, 2023, 09:47:05 AM
Merited by pooya87 (2), Pmalek (2), nc50lc (1), Findingnemo (1)
 #2

If you check the transaction history of the address, you will see that it has received 50 BTC in 2009.
That transaction is not recognized by electrum, because that's a P2PK transaction and the 50 BTC hasn't been paid to that address at all. That transaction has been made to the public key which generates that address.

Many block explorers display the fund that has been sent to a public key for the address derived from that, but electrum doesn't do that.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
johnal (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
October 28, 2023, 10:05:59 AM
 #3

Thanks, to better understand, "if" I own the private key associated with this address, then:
My balance is 30.99099822 BTC.
which includes:
- the 30 BTC from the P2PK transaction made in 2009.
- The 0.99 BTC that Electrum recognizes as confirmed for that address

But I can still spend 30.99 btc, right? If yes, I don't understand Electrum decision to exclude P2PK balances from the address balance!
hosseinimr93
Legendary
*
Offline Offline

Activity: 2380
Merit: 5235



View Profile
October 28, 2023, 10:16:19 AM
Last edit: October 29, 2023, 08:04:20 AM by hosseinimr93
 #4

Thanks, to better understand, "if" I own the private key associated with this address, then:
My balance is 30.99099822 BTC.
If you own the private key of that address, you own  30.99 BTC, but you have to use another tool for spending that. Electrum will display only 0.00099822

Edit: It's possible to sweep the private key in electrum. Read nc50lc's reply.


- the 30 BTC from the P2PK transaction made in 2009.
The (public key of) address received 50 BTC in 2009, spent 19.01 BTC of that and received 30.99 BTC as change.


- The 0.99 BTC that Electrum recognizes as confirmed for that address
0.00099822 BTC.
That's the total amount the address received through P2PKH transactions.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Findingnemo
Hero Member
*****
Offline Offline

Activity: 2324
Merit: 757


Bitcoin = Financial freedom


View Profile
October 28, 2023, 05:51:11 PM
Merited by The Sceptical Chymist (2), Pmalek (2)
 #5

I don't understand Electrum decision to exclude P2PK balances from the address balance!

No one really uses it anymore so they didn't want to add that feature that no one will ever use it anymore. But if you are someone you can create a script to broadcast P2PK transactions via Electrum too.

You can find the relevant discussion about Electrum can't handle "send to pubkey" inputs created by LoyceV

Or better go with Bitcoin core which supports P2PK and every available kind and it definitely worth it if you want to spend your 30BTC. Wink

███████████████████████████
███████▄████████████▄██████
████████▄████████▄████████
███▀█████▀▄███▄▀█████▀███
█████▀█▀▄██▀▀▀██▄▀█▀█████
███████▄███████████▄███████
███████████████████████████
███████▀███████████▀███████
████▄██▄▀██▄▄▄██▀▄██▄████
████▄████▄▀███▀▄████▄████
██▄███▀▀█▀██████▀█▀███▄███
██▀█▀████████████████▀█▀███
███████████████████████████
.
.Duelbits.
..........UNLEASH..........
THE ULTIMATE
GAMING EXPERIENCE
DUELBITS
FANTASY
SPORTS
████▄▄█████▄▄
░▄████
███████████▄
▐███
███████████████▄
███
████████████████
███
████████████████▌
███
██████████████████
████████████████▀▀▀
███████████████▌
███████████████▌
████████████████
████████████████
████████████████
████▀▀███████▀▀
.
▬▬
VS
▬▬
████▄▄▄█████▄▄▄
░▄████████████████▄
▐██████████████████▄
████████████████████
████████████████████▌
█████████████████████
███████████████████
███████████████▌
███████████████▌
████████████████
████████████████
████████████████
████▀▀███████▀▀
/// PLAY FOR  FREE  ///
WIN FOR REAL
..PLAY NOW..
View ArchiveReport to moderator
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10521



View Profile
October 29, 2023, 04:58:17 AM
Merited by Pmalek (2), hosseinimr93 (2)
 #6

But I can still spend 30.99 btc, right? If yes, I don't understand Electrum decision to exclude P2PK balances from the address balance!
Electrum is not excluding that balance, the block explorers you check are falsely displaying the P2PK balance as the P2PKH balance. Imagine if you had two checking account in bank A and bank B, you won't see your balance B when you check your A account and vice versa, even though both of them are your bank accounts and you spend from both using the same signature.

In Bitcoin you can create a lot of different addresses using the same key pair. 2x P2PK, 2x P2PKH, multiple P2SH with various scripts (eg. 1of1 multisig, locktime, conditionals, wrapped witness), 2x P2WPKH, multiple P2WSH with various scripts, multiple P2TR.

But when you create a wallet with that key, the wallet has to know which type of output script (or address) it needs to watch. So when you import your key and select the P2PKH address or import P2PKH address in a watch only wallet it will only watch the P2PKH outputs and report that balance. Which means everything else including P2PK outputs will be ignored.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
nc50lc
Legendary
*
Offline Offline

Activity: 2394
Merit: 5578


Self-proclaimed Genius


View Profile
October 29, 2023, 05:01:10 AM
Merited by hosseinimr93 (2)
 #7

But I can still spend 30.99 btc, right? If yes, I don't understand Electrum decision to exclude P2PK balances from the address balance!
With Electrum, your only option is to "Sweep" its private key (Wallet->Private key->Sweep) and Electrum will be able to spend that P2PK unspent txn output.
When sweeping, do not append any script type before the private key (it wont work in uncompressed WIF) and it'll search for P2PK together with P2PKH outputs.
Take note that sweep automatically sends the amount of BTC to the wallet where you've used the menu.

Reference PR: https://github.com/spesmilo/electrum/pull/3125

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
LoyceV
Legendary
*
Offline Offline

Activity: 3290
Merit: 16581


Thick-Skinned Gang Leader and Golden Feather 2021


View Profile WWW
October 29, 2023, 12:28:33 PM
Merited by Pmalek (2)
 #8

Electrum is not excluding that balance, the block explorers you check are falsely displaying the P2PK balance as the P2PKH balance.
While technically correct, I think it's a good choice to display the information. The block explorer knows for a fact that the same private key can access the funds, so why risk someone overlooking his funds?

With Electrum, your only option is to "Sweep" its private key (Wallet->Private key->Sweep) and Electrum will be able to spend that P2PK unspent txn output.
The main drawback: you need a hot wallet, and can't sign offline. I'd always recommend an offline setup with Bitcoin Core for these amounts.

pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10521



View Profile
October 30, 2023, 12:54:06 PM
Merited by LoyceV (2)
 #9

Electrum is not excluding that balance, the block explorers you check are falsely displaying the P2PK balance as the P2PKH balance.
While technically correct, I think it's a good choice to display the information. The block explorer knows for a fact that the same private key can access the funds, so why risk someone overlooking his funds?
Nah, it's just a weird decision they made for only P2PK outputs. For example if you had funds in P2WPKH address and checked the P2PKH address derived from the same key, the explorer still won't show you the balance in the P2WPKH address.

What they do is basically to take P2PK outputs and convert them to P2PKH. That's it!

There are a bunch of these types of little bugs in block explorers. For example majority of them count the 50BTC reward of Genesis block as the balance of its "address". For those who don't know this reward is not spendable so it should not be included as the balance.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: [1]
  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!