Post
Topic
Board Electrum
Merits 1 from 1 user
Re: [TUTORIAL] How to extract Bitcoin Gold from a 2fa Electrum Wallet [STEP BY STEP]
by
HCP
on 29/01/2018, 20:54:19 UTC
⭐ Merited by LeGaulois (1)
     "error": "Operation not valid with the current stack size"

This same error is present in the first signrawtransaction output as well. I am not sure why it happens.
The "error" generally occurs for a MultiSig transaction when it has not been signed with the minimum required number of private keys (for Electrum 2FA, this is 2-of-3)... Obviously, after the first "signrawtransaction", it's only been signed with one key... However, if you are getting that on the second "signrawtransaction" then one of two things had occurred:

1. You have used the wrong private key (or keys) to sign the transaction... So the redeemscript is not evaluating correctly
Or
2. You didn't use the output from the first signrawtransaction as the TX_HASH for the second signrawtransaction, so you've still only signed it with one key


Quote
In your guide, you do not specify anything for AMOUNT_TO_SEND in the createrawtransaction for wallets with more than 1 input. So I decided to add together all the 'value' amounts from 4 transaction IDs, minus fee (100000 satoshi) and converted it to BTC. If I did it wrong, please, correct me.
Just a note, it's not "my" guide Wink

But yes, same rules apply... Simply tally up the values from the inputs, subtract the fee you wish to pay (100,000 seems like a LOT!!?! Shocked) and put the value in BTC!

You can easily use 10sats/byte fee on BTG... So unless your transaction is HUGE with more than 50 inputs you shouldn't need more than around (10*148*number of inputs)+44 sats as a fee

Ie. 5 inputs = (10*148*5) + 44 = 7444 sats.

Quote
However, there was one VERY interesting and also confusing moment along the way, at the very beginning. When I ran the deserialize(gettransaction("dc7995b5b2756c85657803519569c2203e7d18ff3bae7679f1a4b579cf9fca6c")) I got two outputs and none of them matched the address I was considering (even though in your guide you say it has to). However, the very first output actually matched my other address from the 'Change' section. And this transaction ID(dc7995b5b2756c85657803519569c2203e7d18ff3bae7679f1a4b579cf9fca6c) is also related to that other wallet.  So this particular moment was agains the plan and I simply decided to take the data from this first output, even though it did not match they address I considered.
If you used an input from a different (change) address, then you obviously also need to use the private keys for THAT address... They will be different.

Also, if you are using inputs from multiple addresses in one transaction (ie. Your address "that you considered" and your change address) them you need to sign the transaction with keys from BOTH addresses like so:

Code:
signrawtransaction "RAW_TRANSACTION_HASH" '[{"txid": "INPUT_TRX_ID_AddressA", "vout": PREVOUT_AddressA, "scriptPubKey": "INPUT_SCRIPT_PUB_KEY_AddressA", "redeemScript": "REDEEM_SCRIPT_AddressA", "amount": "INPUT_VALUE_FIELD_Trans1"},{"txid": "INPUT_TRX_ID_AddressB", "vout": PREVOUT_AddressB, "scriptPubKey": "INPUT_SCRIPT_PUB_KEY_AddressB", "redeemScript": "REDEEM_SCRIPT_AddressB", "amount": "INPUT_VALUE_FIELD_Trans2"}]' '["FIRST_PRIVATE_KEY_FOR_SIGNING_AddressA","FIRST_PRIVATE_KEY_FOR_SIGNING_AddressB"]'


You then feed the output of this to the second signrawtransaction and use the 2nd key for each address (note that everything else stays the same, ONLY the private keys and the input hash will be different:
Code:
signrawtransaction "HASH_OUTPUT_FROM_FIRST_SIGNRAWTX" '[{"txid": "INPUT_TRX_ID_AddressA", "vout": PREVOUT_AddressA, "scriptPubKey": "INPUT_SCRIPT_PUB_KEY_AddressA", "redeemScript": "REDEEM_SCRIPT_AddressA", "amount": "INPUT_VALUE_FIELD_Trans1"},{"txid": "INPUT_TRX_ID_AddressB", "vout": PREVOUT_AddressB, "scriptPubKey": "INPUT_SCRIPT_PUB_KEY_AddressB", "redeemScript": "REDEEM_SCRIPT_AddressB", "amount": "INPUT_VALUE_FIELD_Trans2"}]' '["SECOND_PRIVATE_KEY_FOR_SIGNING_AddressA","SECOND_PRIVATE_KEY_FOR_SIGNING_AddressB"]'


Quote
I have digged further and tried excluding the txid mentioned above from the 'createrawtransaction' and use the remaining 3 txid's and a sum of their balances for AMOUNT_TO_SEND. Just pretending this txid does not exist. Eventually I do get "complete":true in the end. However, when I try to send this transaction I get Missing inputs (code -25). So I have tried various combinations and still cannot figure it out.
"Missing inputs" means the inputs you are attempting to spend don't exist in the current UTXO set. This is generally because either:

1. The parent transaction never confirmed and has been dropped (so the input doesn't exist)
Or
2. The input has already been spent (so that input doesn't exist anymore)


Also, one thing that has tripped people up previously... You ONLY subtract the fee in the "createrawtransaction" when calculating AMOUNT_TO_SPEND. When putting the amounts in "signrawtransaction" commands, these need to match the original amount!