1

I am new to bitcoin so please bear my question. To understand the IN's and OUT's of this crypto world, i am creating a dummy bank to have a better understanding of the system.

So I have a bitcoin core running in my local system. Now for each user in the system I create an account for them using the getaccountaddress.

So let us consider I have one account named A having a deposit of 10 BTC. Now, suppose the user A wish to withdraw 1BTC from his account so, I first find all unspent transactions filter it by address associated by account A and send this 1BTC to user A. Now as I understand that the bitcoin cannot be partially spent so the remaining change will go to a change address so I provided account A's address from which the transaction was created.

Now my problem is that if the user again wishes to withdraw, I cannot find any unspent transaction since the change is not yet received immediately and will only be available when the transaction is confirmed. So what is better way to handle this? What is a typical standard to handle such situation? How does wallet like Electrum works as I can see that I can send multiple transactions one after another.

  • Why send them one after another rather than aggregating them into a single transaction? – David Schwartz May 31 at 16:49
  • How about an order processing system where I wish to process an order as soon as I receive? – Paras May 31 at 17:39
  • Then I'd just treat all the bitcoins that I had as one common pool. If the payment was on behalf of a particular account, I'd debit that account for the payment but I wouldn't try to use segregated bitcoins for each account, it makes things much less efficient. When you have $10,000 at a bank, there's no specific bills they have that are your $10,000 -- that's what creates the problem you're having. – David Schwartz May 31 at 17:42
  • I got your point. ;-) – Paras May 31 at 17:46
  • can you help me with this? bitcoin.stackexchange.com/questions/88085/… – Paras May 31 at 17:47
0

Confirmation concept is generally useful for the counterparty to be sure that the transaction through which he has received the BTC cannot be reversed. Nothing stops you from creating a new transaction referencing the outpoints (txid and n) of the transaction through which you just spent your 1BTC, if you do not plan on changing the previously broadcasted transaction by say a higher fee. Either both transactions can get mined in the single block, or the second transaction can get mined in block after the first transaction has been mined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.