Bitcoin Forum
April 24, 2024, 12:35:41 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Transaction not showing up on network, but exists on local client  (Read 990 times)
moocoin (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10

Do you moo?


View Profile WWW
May 05, 2014, 04:48:54 PM
 #1

Hiya,
I used SendToAddress to send some btc from my wallet to a blockain.info wallet.  bitcoind returned a txid, so I'm assuming it was "successful".
Unfortunately, the txid doesn't show up on the blockchain.info explorer, even after 12 hours.  The local wallet has 8 network connections, and has an up to date blockchain count.

Any thoughts?

Here's the txid: 52d7d2d0a32a5be2c819a168ccf36ca7fbec21007351a43c18491c9c823db8e5
Here's the blockchain.info explorer not finding it:  https://blockchain.info/search/52d7d2d0a32a5be2c819a168ccf36ca7fbec21007351a43c18491c9c823db8e5
Here's the local client listtransactions:
    {
        "account" : "",
        "address" : "1oooooFphUFL6GSY7aukZyELK2Z36Roim",
        "category" : "send",
        "amount" : -0.54838058,
        "fee" : -0.00020000,
        "confirmations" : 0,
        "txid" : "52d7d2d0a32a5be2c819a168ccf36ca7fbec21007351a43c18491c9c823db8e5",
        "time" : 1399248101,
        "timereceived" : 1399248101
    }


1713962141
Hero Member
*
Offline Offline

Posts: 1713962141

View Profile Personal Message (Offline)

Ignore
1713962141
Reply with quote  #2

1713962141
Report to moderator
Remember that Bitcoin is still beta software. Don't put all of your money into BTC!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
telepatheic
Jr. Member
*
Offline Offline

Activity: 56
Merit: 1


View Profile
May 05, 2014, 05:03:56 PM
 #2

Use getrawtransaction 52d7d2d0a32a5be2c819a168ccf36ca7fbec21007351a43c18491c9c823db8e5 to see if your client has remembered the transaction.

If it hasn't you will have to send the transaction from scratch. If it has, it will return a raw transaction which you can paste into here https://blockchain.info/pushtx or here http://blockr.io/tx/push to get the network to see it.
moocoin (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10

Do you moo?


View Profile WWW
May 05, 2014, 05:07:36 PM
 #3

Interesting.  Here's what I get:
"Could not find all input transactions, you might have referenced some input transactions that are not in network"

moocoin (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10

Do you moo?


View Profile WWW
May 05, 2014, 09:08:05 PM
 #4

This appears to be the root of the problem.  My client has this transaction:
39445bebc8b69dbfb020d437dd3738a8fc66681b507a75363729919ef47c3e02

Here is the output of getrawtransaction:
0100000001edc13c11e603787b66d764d518483852d31ff5ad40a92fef9e3f94e830c3e5c501000 0006c493046022100ffe7d367ae2cff45db200b1377ab023d3eaa989e21f7c9bd8791c11222799b 35022100bb906cbe08559d46c44f4f8ccea094787f37d0479b49fe7331d417de214f3df60121020 c12d127683f84315d701832383a41fc063502cc50fd4d8b56c68176df1903b4ffffffff02723346 00000000001976a914b69925f93434c2fa296c7f2e994df5b0c2bfd56488ac580f0200000000001 976a914e1acf118a792ad15264b6e4543d66afbc9372c7b88ac00000000

On decode, it shows this:
 "lock_time":0,
   "inputs":[
      {
         "prev_out":{
            "index":1,
            "hash":"c5e5c330e8943f9eef2fa940adf51fd352384818d564d7667b7803e6113cc1ed"
         },
         "script":"493046022100ffe7d367ae2cff45db200b1377ab023d3eaa989e21f7c9bd8791c11222799b35022 100bb906cbe08559d46c44f4f8ccea094787f37d0479b49fe7331d417de214f3df60121020c12d1 27683f84315d701832383a41fc063502cc50fd4d8b56c68176df1903b4"
      }
   ],
   "vout_sz":2,
   "hash":"39445bebc8b69dbfb020d437dd3738a8fc66681b507a75363729919ef47c3e02",
   "vin_sz":1,
   "out":[
      {
         "address":"1HeVSr4fY9vHsNYQW54Ln6dvqBdACtrZzg",
         "script_string":"OP_DUP OP_HASH160 b69925f93434c2fa296c7f2e994df5b0c2bfd564 OP_EQUALVERIFY OP_CHECKSIG",
         "value":4600690,
         "script":"76a914b69925f93434c2fa296c7f2e994df5b0c2bfd56488ac"
      },
      {
         "address":"1MaGDNKRsbaTFPZ37xEVrxW722ZnHFyhwX",
         "script_string":"OP_DUP OP_HASH160 e1acf118a792ad15264b6e4543d66afbc9372c7b OP_EQUALVERIFY OP_CHECKSIG",
         "value":135000,
         "script":"76a914e1acf118a792ad15264b6e4543d66afbc9372c7b88ac"
      }
   ],
   "size":227,
   "version":1


When I try to push it to the network, I get:
An outpoint is already spent in [DBBitcoinTx [txIndex=47534292,  getEstimatedBTCSent()=0, isGeneratedBlockReward()=false, getTotalBTCSent()=0, getHash()=518fc4bf6cfbe142c29fd54f2d623807ce02c19d88c48d0185bc16f8e14fa41a, getVersion()=1, getSize()=231, toString()=BitcoinTx{hash=518fc4bf6cfbe142c29fd54f2d623807ce02c19d88c48d0185bc16f8e14fa41a, version=1, lockTime=0, in=[], out=[]}, getClass()=class piuk.blockchain_db.DBBitcoinTx]] [(47477784, 1)]

How can an output already be spent if the transactionId doesn't show up on the blockchain?

DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
May 05, 2014, 09:12:32 PM
 #5

It doesn't mean the output of your transaction.  All INPUTS reference a prior unspent output.  So when the error says the output has been spent it means "the transaction you are creating has one or more inputs which reference outputs that are already spent.  Only unspent outputs can be referenced by inputs so the created transaction is invalid"


Per your transaction:

Quote
 "inputs":[
      {
         "prev_out":{
            "index":1,
            "hash":"c5e5c330e8943f9eef2fa940adf51fd352384818d564d7667b7803e6113cc1ed"
         },
         "script":"493046022100ffe7d367ae2cff45db200b1377ab023d3eaa989e21f7c9bd8791c11222799b35022 100bb906cbe08559d46c44f4f8ccea094787f37d0479b49fe7331d417de214f3df60121020c12d1 27683f84315d701832383a41fc063502cc50fd4d8b56c68176df1903b4"
      }
   ]

Index is zero based as index 1 means the second output.  Per blockchain.info it that output has already been spent in another transaction.  Outputs can only be spent once.  For some reason your client believed that output was unspent and thus tried to spend it in a new transaction.  It can't and that is why you are getting an error.

https://blockchain.info/tx/c5e5c330e8943f9eef2fa940adf51fd352384818d564d7667b7803e6113cc1ed

You are attempting to double spend that output and it was already spent and included in a block 3 months ago.  
moocoin (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10

Do you moo?


View Profile WWW
May 05, 2014, 09:53:07 PM
 #6

Got it.  Thanks for the explanation.

So, how do I fix this?  I'm assuming after some time, my client will realize that the transaction isn't happening and will "reclaim" the erroneous transaction?
If so, how do I get it to realize that the outputs are spent for that transaction?

Thanks!

DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
May 05, 2014, 09:57:44 PM
 #7

Well I am not sure how it happened.  I don't think the QT client will ever delete a tx even one that later turns out to be invalid.  To do that would require a tool like pywallet.  You want to delete the tx not the private key.  Always make a backup.

Once you do that replace the modified wallet.dat with the unmodified one and restart with a -rescan option.   The client should be aware that the output in question has been spent.

One way to verify is from the debug console use "listunspent" this will show all the unspent outputs.  There should be no entry for txid c5e5c330e8943f9eef2fa940adf51fd352384818d564d7667b7803e6113cc1ed.  Note if you do this now the txid will not be there but that is because the client doesn't see it as an unspent output because the unconfirmed tx spending it "exists".   So this is only a test once the bad transaction is removed from the client.
moocoin (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10

Do you moo?


View Profile WWW
May 05, 2014, 10:24:42 PM
 #8

Kind of scary that the mainline 80600 command line client can get itself into this situation!
I have backups of the wallet every 1/2 * keypoolsize.  I'll give pywallet and rescan a go.

Thanks!

DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
May 05, 2014, 11:15:56 PM
 #9

I wouldn't say scary.  Frustrating, not exactly user friendly especially if the wallet can't auto recover but there was never any risk of losing funds (even without a backup).  The client was "confused" and unaware that the output in question had been spent (back in Feb).  How or why I am not sure but for lack of a better term it was trying to spend money you didn't have.  The rest of the network reacted correctly by dropping the transaction as invalid.  The recipient could never have been defrauded and you couldn't lose what wasn't your to spend.

The challenge for developers is how to handle these edge cases in a way which allows the wallet to recover cleanly.  Currently when the client finds itself in these edge cases it will remain there and while not a security risk can be confusing to the user.
moocoin (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10

Do you moo?


View Profile WWW
May 07, 2014, 04:36:55 PM
 #10

I removed the transaction with pywallet, and started the daemon with -rescan.  Good new is that the botched transaction is no longer shown in the wallet.
Bad news is that getinfo shows a balance of 0 even though my accounts have positive balances.  Not sure how the balance is calculated, but it's definitely not the sum of the accounts.
I'm going to dump keys, create a new wallet, and import keys to see if that works.

DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
May 07, 2014, 05:49:24 PM
 #11

You sure you deleted the transaction not the private key?  What was your balance prior to removing the tx?  Personally I find accounts totally worthless and devs are looking to remove them in future versions of the client.  What was the overall balance before and after using pywallet?  Hopefully you created a backup before using pywallet.
moocoin (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10

Do you moo?


View Profile WWW
May 07, 2014, 07:29:33 PM
 #12

Yep - I have backups, so I'm not worried about any of these changes.

Balance before I tried to use sendtoaddress was around .5 btc.
After I sent everything out of the wallet, getinfo showed 0.0 btc, and listtransactions showed the "stuck" transaction that contained the already spent outputs.  It sat that way for a few days.

I went to pywallet and deleted the "stuck" transaction and restarted bitcoind with the -rescan parameter.  After that, listtransactions no longer showed the "stuck" transaction, but the wallet balance was still 0 btc.
Interestingly, a listaccounts showed all of my accounts with positive balances, hence my observation that the getinfo balance isn't simply a sum of the listaccounts balances.

I agree that accounts are sub-optimal.  I don't think they belong in a consumer wallet, and any implementation of them for a business wallet should be outside of the core.

moocoin (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10

Do you moo?


View Profile WWW
May 07, 2014, 07:30:52 PM
 #13

Oh and real quick:  Thanks for the help  Smiley


DeathAndTaxes
Donator
Legendary
*
Offline Offline

Activity: 1218
Merit: 1079


Gerald Davis


View Profile
May 07, 2014, 08:07:18 PM
 #14

Yeah that is very weird.

One way to figure out what is the difference is to run listunpsentoutputs in the debug window after launching the client with the old (unmodified) wallet.

Balance is just the sum of the value of the outputs you have available to spend.  So listunspentoutputs should show a list of one or more outputs with a combined value of 0.5 btc.  Checking them in the blockchain may shed some light on why they are "gone" from the modified wallet.
moocoin (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10

Do you moo?


View Profile WWW
May 08, 2014, 12:10:27 AM
 #15

Restored an old wallet.  Ran listunspentoutputs and checked each against the blockchain to verify it was unspent.  Everything looked good.
I did sendtoaddress on .1 btc to test, and everything went great.

I tried to sendtoaddress on the rest, and it died again.  So weird.
I deleted the transaction, started bitcoind with -rescan, and again it shows a 0 balance for the wallet and does not show the erroneous transaction.  SO weird.

I'm going to restore the old wallet again, rescan, and listunspentoutputs one more time, and verify them against the blockchain one more time to make sure I'm not crazy.


moocoin (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10

Do you moo?


View Profile WWW
May 08, 2014, 12:57:31 AM
 #16

So here's the latest.  bitcoind getinfo shows a balance of 0.44858058
Adding up the amounts of the listunspent outputs is 0.40257368
The discrepancy is 0.0460069
I just did a sendtoaddress for the sum of the unspent outputs (0.40257368), and everything worked.

Here is my current output:
$ bitcoind getinfo
{
    "version" : 80600,
    "protocolversion" : 70001,
    "walletversion" : 60000,
    "balance" : 0.04610690,
    "blocks" : 299627,
    "timeoffset" : 0,
    "connections" : 8,
    "proxy" : "",
    "difficulty" : 8000872135.96816349,
    "testnet" : false,
    "keypoololdest" : 1392649428,
    "keypoolsize" : 10001,
    "paytxfee" : 0.00000000,
    "unlocked_until" : 1399520348,
    "errors" : ""
}
$ bitcoind listunspent
[
    {
        "txid" : "cf60d44bf5f22c3367968e9ee728b09045334780610739fed5fa3ff8db877dfe",
        "vout" : 0,
        "address" : "1QGvXsj4XAELiXiAi198JjKKsf2dNLKfF1",
        "account" : "437ff94080e78804f502929d94d6662f527e18bf89089af41914c2d056e4c5d6",
        "scriptPubKey" : "76a914ff4dd1a8f3728da21d981b6e587ec467dce9616588ac",
        "amount" : 0.00002000,
        "confirmations" : 13069
    }
]

Thank you SO much for the help.  I'm a happy camper now that I at least have the funds out of the wallet.  I wish I knew what caused it, or why there is still a discrepancy between the unspent outputs and the balance.

Dabs
Legendary
*
Offline Offline

Activity: 3416
Merit: 1912


The Concierge of Crypto


View Profile
May 08, 2014, 01:00:47 AM
 #17

There's also a zapwallettx command as of 0.9.0+

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!