Author

Topic: Input not found or already spent - signrawtransaction (Read 248 times)

newbie
Activity: 9
Merit: 0
thanks very much for the answer, clears things up a bit
legendary
Activity: 3472
Merit: 4801
I got it to work but I am still confused.

During the call to signrawtransaction on the cold machine while passing in the raw unsigned hex as 1st arg, i added as 2nd arg the json of used input tx, vout, and scriptPubKey.

Then it worked.

I do not understand why can not the fundrawtransaction command just do that for me on the hot machine and put it directly into the unsigned hex? It knows all the information there. I can see it after running listunspent command on the watchonly hot machine.

As in, how to make fundrawtransaction command on the hot machine use the info it knows there to make the unsigned raw hex ready for signing all by itself on the cold machine, specifically the info obtained by listunspent on the hot machine -- which had to be explicitly specified separately as the 2nd argument to signrawtransaction on the cold machine?

The raw hex transaction already has the used input tx and vout.  What was missing was the scriptPubKey.

I'm not sure why the developers decided not to have fundrawtransaction put the scriptPubKey into the scriptSig area of the unsigned transaction.  It would certainly be nice if fundrawtransaction were to do that, and if signrawtransaction knew to look at the scriptSig of the unsigned rawtransaction to get the scriptPubKey.

I suppose doing that would fix your problem, but might cause problems in other use cases, so it made sense to just have the user provide the scriptPubKey separately (since it is never really supposed to be a part of the transaction itself).
newbie
Activity: 9
Merit: 0
I got it to work but I am still confused.

During the call to signrawtransaction on the cold machine while passing in the raw unsigned hex as 1st arg, i added as 2nd arg the json of used input tx, vout, and scriptPubKey.

Then it worked.

I do not understand why can not the fundrawtransaction command just do that for me on the hot machine and put it directly into the unsigned hex? It knows all the information there. I can see it after running listunspent command on the watchonly hot machine.

As in, how to make fundrawtransaction command on the hot machine use the info it knows there to make the unsigned raw hex ready for signing all by itself on the cold machine, specifically the info obtained by listunspent on the hot machine -- which had to be explicitly specified separately as the 2nd argument to signrawtransaction on the cold machine?
newbie
Activity: 9
Merit: 0
quick bump since i modified the OP
newbie
Activity: 9
Merit: 0
ok i figured out the OP but now i have another problem. I replaced the OP with this.

Here is the summary up to this point:


bitcoin core 0.15.1 running on offline machine, wallet w priv keys, no blockchain


bitcoin core 0.15.1 running on online machine, full blockchain and did this:
    (mgKZtvQGQwNKExhPPev7ahUQozZjeJ9Qv8 is an address from the offline cold wallet, that is to be watch only on online machine)

./bitcoin-cli -testnet importaddress "mgKZtvQGQwNKExhPPev7ahUQozZjeJ9Qv8"

and then did a rescan.

(edited from original for better explaining)
I then ran "createrawtransaction" with empty inputs.

After that I ran "fundrawtransaction" to fill in inputs and was stopped by "Insufficient Funds" problem so i did this:
(end edit)

./bitcoin-cli -testnet importpubkey "028be566dd426e4299c0d6b2dd7dffe74b6eee9b24c3c069f802815e91d19fe6a1" "testwatch" true

This fixed the solvable:false / "Insufficient Funds" problem and "fundrawtransaction" was able to produce raw unsigned of:

02000000016084765d9d69a4be9eef7666b2283ddb3c2b8df4f63e6a49ffb255493b53192100000 00000fdffffff0480d1f008000000001976a914406baac9f88434a506016140050b3356832a59b2 88ac80d1f008000000001976a914c0050df3bdbcd89492a71468c0a04571d547c45388ac80d1f00 8000000001976a91447e11495c1fb92294df5727866ed72f60e9aa92c88acb35251070000000019 76a91400120f4e738e4d77a89fc01124a9228a303125f388ac00000000

The json of that is:

{
  "hash": "f4b824db9db3f7c46153afedaac6e10d8d2b3a01424a646d4621ef539cd084cb",
  "vout": [
    {
      "scriptPubKey": {
        "reqSigs": 1,
        "hex": "76a914406baac9f88434a506016140050b3356832a59b288ac",
        "addresses": [
          "mmPaXB8eaSELLj9qPA4Aeuu1M86CVeoDVK"
        ],
        "asm": "OP_DUP OP_HASH160 406baac9f88434a506016140050b3356832a59b2 OP_EQUALVERIFY OP_CHECKSIG",
        "type": "pubkeyhash"
      },
      "value": 1.5,
      "n": 0
    },
    {
      "scriptPubKey": {
        "reqSigs": 1,
        "hex": "76a914c0050df3bdbcd89492a71468c0a04571d547c45388ac",
        "addresses": [
          "my2G65VgkcUDfB2KffGqJ837tRkaA1hPCN"
        ],
        "asm": "OP_DUP OP_HASH160 c0050df3bdbcd89492a71468c0a04571d547c453 OP_EQUALVERIFY OP_CHECKSIG",
        "type": "pubkeyhash"
      },
      "value": 1.5,
      "n": 1
    },
    {
      "scriptPubKey": {
        "reqSigs": 1,
        "hex": "76a91447e11495c1fb92294df5727866ed72f60e9aa92c88ac",
        "addresses": [
          "mn51uXz97cJxSmBSaEzWDaBkkU8JHhjX89"
        ],
        "asm": "OP_DUP OP_HASH160 47e11495c1fb92294df5727866ed72f60e9aa92c OP_EQUALVERIFY OP_CHECKSIG",
        "type": "pubkeyhash"
      },
      "value": 1.5,
      "n": 2
    },
    {
      "scriptPubKey": {
        "reqSigs": 1,
        "hex": "76a91400120f4e738e4d77a89fc01124a9228a303125f388ac",
        "addresses": [
          "mfXKvsRtsQq8pikw7MJWErRaiQDD4JbDmH"
        ],
        "asm": "OP_DUP OP_HASH160 00120f4e738e4d77a89fc01124a9228a303125f3 OP_EQUALVERIFY OP_CHECKSIG",
        "type": "pubkeyhash"
      },
      "value": 1.22770099,
      "n": 3
    }
  ],
  "vin": [
    {
      "sequence": 4294967293,
      "scriptSig": {
        "hex": "",
        "asm": ""
      },
      "vout": 0,
      "txid": "2119533b4955b2ff496a3ef6f48d2b3cdb3d28b26676ef9ebea4699d5d768460"
    }
  ],
  "txid": "f4b824db9db3f7c46153afedaac6e10d8d2b3a01424a646d4621ef539cd084cb",
  "version": 2,
  "locktime": 0,
  "vsize": 187,
  "size": 187
}


Ok so i take the raw transaction hex to the offline machine and run:

Code:
./bitcoin-cli -testnet signrawtransaction "02000000016084765d9d69a4be9eef7666b2283ddb3c2b8df4f63e6a49ffb255493b5319210000000000fdffffff0480d1f008000000001976a914406baac9f88434a506016140050b3356832a59b288ac80d1f008000000001976a914c0050df3bdbcd89492a71468c0a04571d547c45388ac80d1f008000000001976a91447e11495c1fb92294df5727866ed72f60e9aa92c88acb3525107000000001976a91400120f4e738e4d77a89fc01124a9228a303125f388ac00000000"

and get an error: "Input not found or already spent". I can see on a blockexplorer site there is enough funds.
The priv key for the address mgKZtvQGQwNKExhPPev7ahUQozZjeJ9Qv8 is definitely in the wallet being used.

I thinking the blank scriptSig area in the vin in the unsigned json has something to do with it. How to get that filled in? I saw this post:
https://bitcointalksearch.org/topic/m.16316997
and I think it has something do with needing "All the redeem scripts of any P2SH inputs". Does this fix the blank scriptSig?

If that it somebody please tell me how to do this i am stumped. Like i said earlier, on the online machine with full blockchain that makes the raw unsigned i did:
Code:
./bitcoin-cli -testnet importaddress "mgKZtvQGQwNKExhPPev7ahUQozZjeJ9Qv8"
./bitcoin-cli -testnet importpubkey "028be566dd426e4299c0d6b2dd7dffe74b6eee9b24c3c069f802815e91d19fe6a1" "testwatch" true
and rescanned

and then "createrawtransaction" with blank inputs and then "fundrawtransaction"


THanks so much for any helps!

Jump to: