Bitcoin Forum
December 08, 2016, 09:53:50 AM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Negative balances & Moving coins- 2 questions  (Read 1501 times)
Westermarck
Newbie
*
Offline Offline

Activity: 3


View Profile
April 16, 2011, 05:12:11 AM
 #1

1) It's possible to have a negative balance in an address. How is this possible? What's to stop me spending more bitcoins than I own?

2) How does moving coins work? AFAIK, it's not a transaction. Are they just stored as <PubKeyHash> OP_CHECKSIG in the new address, and when sending from that address it broadcasts a dual script like:

<PubKeyHash> OP_CHECKSIG <PubKeyHashNewAddress> OP_CHECKSIG

?
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481190830
Hero Member
*
Offline Offline

Posts: 1481190830

View Profile Personal Message (Offline)

Ignore
1481190830
Reply with quote  #2

1481190830
Report to moderator
1481190830
Hero Member
*
Offline Offline

Posts: 1481190830

View Profile Personal Message (Offline)

Ignore
1481190830
Reply with quote  #2

1481190830
Report to moderator
theymos
Administrator
Legendary
*
expert
Offline Offline

Activity: 2492


View Profile
April 16, 2011, 05:33:28 AM
 #2

1) It's possible to have a negative balance in an address. How is this possible? What's to stop me spending more bitcoins than I own?

It's not actually possible to have a negative balance. Any negative balances you see are UI quirks. AFAIK, only the "" account is supposed to be able to have a negative balance.

2) How does moving coins work? AFAIK, it's not a transaction.

The balances are just changed. No transaction stuff is done.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
Westermarck
Newbie
*
Offline Offline

Activity: 3


View Profile
April 16, 2011, 05:48:30 AM
 #3

1) It's possible to have a negative balance in an address. How is this possible? What's to stop me spending more bitcoins than I own?

It's not actually possible to have a negative balance. Any negative balances you see are UI quirks. AFAIK, only the "" account is supposed to be able to have a negative balance.

And you can only get a negative "" balance when you move coins from there to another account, right?

If that's the case then why is it only with the "" account?

Quote
2) How does moving coins work? AFAIK, it's not a transaction.

The balances are just changed. No transaction stuff is done.

OK, so the client moves addresses between accounts when you do a move?
theymos
Administrator
Legendary
*
expert
Offline Offline

Activity: 2492


View Profile
April 16, 2011, 06:26:57 AM
 #4

And you can only get a negative "" balance when you move coins from there to another account, right?

If that's the case then why is it only with the "" account?

Usually it happens when you send money without using sendfrom. The payment comes from "", and it only fails if the wallet as a whole has insufficient funds.

OK, so the client moves addresses between accounts when you do a move?

No. It just changes the amount of BTC associated with that account in the database. You can move addresses with setaccount.

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652


Chief Scientist


View Profile WWW
April 16, 2011, 01:22:22 PM
 #5

There are actually a few different ways to get a negative account balance.

1. As theymos said, the "" account is special, and can go negative if you use sendtoaddress instead of sendfrom.

2. Other accounts can go negative if they receive coins on a bitcoin address, you send those coins from that account, and then you use setaccount to re-assign those received coins to some other account.

3. They can also go negative by the transaction fee amount if you sendfrom the coins in an account and the send needs a transaction fee.

Also as theymos says, you can never send more coins than are in your total wallet.  And it should ALWAYS be true that the sum of coins in all accounts equals the number of coins you can send.

How often do you get the chance to work on a potentially world-changing project?
doldgigger
Full Member
***
Offline Offline

Activity: 170


View Profile
July 13, 2011, 09:44:35 AM
 #6

3. They can also go negative by the transaction fee amount if you sendfrom the coins in an account and the send needs a transaction fee.
I'm currently having this case. I wanted to test if the client would add a transaction fee, so I sent the full balance of an account using sendfrom, assuming that it will either go through if there is no transaction fee, or it would be rejected because the account had insufficient funds. But instead, it went through, resulting in a negative balance. And the transaction doesn't get confirmed.

As you are writing this is expected behaviour, does this mean the transaction will eventually get confirmed at some point (if so, how will it be funded?)? Or do I have to do something in order to recover the coins?

19orEcoqXQ5bzKbzbAnbQrCkQC5ahSh4P9
Feel free to PM me for consulting and development services.
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652


Chief Scientist


View Profile WWW
July 13, 2011, 11:28:33 AM
 #7

As you are writing this is expected behaviour, does this mean the transaction will eventually get confirmed at some point (if so, how will it be funded?)? Or do I have to do something in order to recover the coins?
It will get confirmed; it is already 'funded' (you can never send more coins than you have in total in your wallet).

This example might help; if you have exactly two accounts in your bitcoin wallet and their balances are:

Account A: -0.1 BTC
Account B: 1 BTC

... then if you tried to send 1 btc from account B the send would fail with an "insufficient funds" error.

I'd suggest funding a 'TransactionFees' account, and then when a sendfrom results in transaction fees reimburse the account by moving funds from TransactionFees.

How often do you get the chance to work on a potentially world-changing project?
doldgigger
Full Member
***
Offline Offline

Activity: 170


View Profile
July 13, 2011, 11:53:17 AM
 #8

As you are writing this is expected behaviour, does this mean the transaction will eventually get confirmed at some point (if so, how will it be funded?)? Or do I have to do something in order to recover the coins?
It will get confirmed; it is already 'funded' (you can never send more coins than you have in total in your wallet).

This example might help; if you have exactly two accounts in your bitcoin wallet and their balances are:

Account A: -0.1 BTC
Account B: 1 BTC

... then if you tried to send 1 btc from account B the send would fail with an "insufficient funds" error.

Yeah, this seems logical. If it wasn't that way, I could just send more coins than I have to another wallet, and delete the wallet with the negative balance in order to create free coins Wink

I just thought I would trigger an error already by maxing out one account.


I'd suggest funding a 'TransactionFees' account, and then when a sendfrom results in transaction fees reimburse the account by moving funds from TransactionFees.

So are you saying the transaction will go through after I put the negative balance account to a positive value again by moving funds from another account?

Or will it go through anyway without me interfering (although I assume this is not the case as it has been lying around unconfirmed for 3 hours now)?

19orEcoqXQ5bzKbzbAnbQrCkQC5ahSh4P9
Feel free to PM me for consulting and development services.
JoelKatz
Legendary
*
Offline Offline

Activity: 1386


Democracy is vulnerable to a 51% attack.


View Profile WWW
July 13, 2011, 01:29:46 PM
 #9

1) It's possible to have a negative balance in an address. How is this possible? What's to stop me spending more bitcoins than I own?
There really is no such thing as an address balance. The client is showing account balances.

You can try to spend more bitcoins than you own. For example, you could form one transaction to send 10 bitcoins to me and another transaction to send those same 10 bitcoins to someone else. You could broadcast both transactions. You could consider a -20 charge to the account. But it is not possible for both transactions to get in the public hash chain because the public hash chain is the longest *valid* chain and no chain containing two transactions that claim the same funds is valid.

Quote
2) How does moving coins work? AFAIK, it's not a transaction. Are they just stored as <PubKeyHash> OP_CHECKSIG in the new address, and when sending from that address it broadcasts a dual script like:
I'm not sure I understand what you're asking. If you mean moving coins to another address, then it takes a transaction. If you mean moving them to another account, that's just a number in the client.

I am an employee of Ripple.
1Joe1Katzci1rFcsr9HH7SLuHVnDy2aihZ BM-NBM3FRExVJSJJamV9ccgyWvQfratUHgN
riush
Member
**
Offline Offline

Activity: 73


View Profile
July 13, 2011, 07:15:02 PM
 #10

There really is no such thing as an address balance. The client is showing account balances.

So can the fee only be taken from another address within the same account, or also from another account, if there is nothing left in the one I'm sending from? (with the exception of "" of course)

1MKKiJhUJgqKyfCLeo7bB1bvELNEM8wUbz
JoelKatz
Legendary
*
Offline Offline

Activity: 1386


Democracy is vulnerable to a 51% attack.


View Profile WWW
August 01, 2011, 08:10:27 AM
 #11

So can the fee only be taken from another address within the same account, or also from another account, if there is nothing left in the one I'm sending from? (with the exception of "" of course)
The accounts are basically mythical. The fee is taken from your balance. Which account it is debited from is a meaningless accounting issue. The client only "sort of" tracks funds by account.

There are bitcoin addresses that people send money to. Each address has a corresponding key. There is a very real "balance" that can be claimed with that key.

The bitcoin client knows all the bitcoins its funds can claim. For convenience, it separates them into accounts. When money is sent to a particular address, the client credits it to the corresponding account for your convenience.

Other than that automatic crediting of the account an address is associated with, the account balances are mythical.

I am an employee of Ripple.
1Joe1Katzci1rFcsr9HH7SLuHVnDy2aihZ BM-NBM3FRExVJSJJamV9ccgyWvQfratUHgN
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!