Author

Topic: Is the transfer of a P2SH-P2PK address+key to Bitcoin Core doable? (Read 280 times)

newbie
Activity: 8
Merit: 0
@goatpig  Thanks for your very clear explanation.  I think I am close to having a working fork of Jimmy Song's tool (https://github.com/jimmysong/hardforkhelp) for forks that works with P2SH.   I'll post a link here when I have tested it a bit more.

legendary
Activity: 3794
Merit: 1375
Armory Developer
Quote
goatpig, would it be possible for you to list a sequence of bitcoin-cli commands

I don't think such a thing exists. You need to craft the TxIn manually basically. I'll give you a little run down so you understand what's going on. At the binary level, a legacy bitcoin tx looks like this:

Code:
version (4 bytes)

TxIn count (varint)
TxIns

TxOut count (varint)
TxOuts

LockTime (4 bytes)

TxIns looks like this:

Code:
Outpoint (32bytes txhash + 4bytes txout index)
scriptsig
sequence (4bytes)

And TxOuts look like this:

Code:
value (8 bytes)
scriptPubKey

Whenever you want to redeem an output, you have to point at it in your input as an outpoint (hash + index), and the scriptSig field of your input has to satisfy the scriptPubKey script of the outpoint. The fundamental difference between P2PKH and P2SH is this:

- P2PKH always refers to a public key hash, therefor a fulfilled scriptSig will always look like this: (pubKey|sig)

- P2SH refers to the hash of any valid script. The scriptSig needs to reveal the hash preimage (the actual script itself) and also fulfill the execution of that script. Typically a scriptSig for P2SH looks like this:

Code:
OP_PUSHDATA | (P2SH script) | OP_PUSHDATA | (script fulfillment)

In the case of P2SH-P2PK used in Armory, the P2SH script is just this:

https://github.com/goatpig/BitcoinArmory/blob/master/cppForSwig/Wallets.cpp#L2673

So the scriptSig would look like this:

Code:
OP_PUSHDATA | (33 | compressed pubkey | OP_CHECKSIG) | OP_PUSHDATA | sig

------------------------------

In order for bitcoin-cli to generate this unsigned tx for you, it would have to have some sort of interface where you can import a P2SH address with the underlying P2SH script. I don't think such interface exists right now (I remember discussing with other devs how that would be the way forward for importing custom scripts a few months ago). This leaves having to craft the unsigned tx manually, then getting bitcoin-cli to sign for it (which I believe is pretty straight forward).

Basically you'd have to spend a couple hours learning about Bitcoin transactions and how to get Core to sign a raw tx. Then you have to craft the tx and get it signed. Just be careful about overspending on fees. The testnet is there for trying stuff around anyways.
newbie
Activity: 8
Merit: 0

It is true that if you are not technical and wish to withdraw coins from an Armory specific script type on whatever air drop fork, you would have to wait for someone else to make that code available to you. If you're aggressively after the airdrops, I suggest you stick to legacy P2PKH, as it is the most widely accepted script type.

goatpig, would it be possible for you to list a sequence of bitcoin-cli commands to spend from a P2SH-P2PK address, sending to a single output consisting of a new address?
Example:
I want to spend from P2SH-P2PK address ADDR0 (which is created in TRX0 as sole output #0) to a new address ADDR1.
Assume I have have PRIVKEY0 which corresponds to ADDR0 available.

Alternatively is there documentation of how to do this for P2SH-P2PK addresses somewhere? Can you provide a link?

Thanks!
newbie
Activity: 8
Merit: 0
nsactions). So, after spending a few more hours on this I managed to feed the BTG signer with the correct data. Problem solved, thank you!

Any chance you can outline what you did to manually create BTG transactions on this thread?  There are others (like me) who are in the same situation.   It would be a big help. Thanks!
newbie
Activity: 3
Merit: 0
Your reply has been heartwarming (and you're right, I'm not technical enough to understand the detailed workings of transactions). So, after spending a few more hours on this I managed to feed the BTG signer with the correct data. Problem solved, thank you!
legendary
Activity: 3794
Merit: 1375
Armory Developer
Does it mean that by using an P2SH-P2PK address I indissolubly and irrecoverably bound my chances to recover forked funds to the fate of Armory?

You're making it sound dreadful on purpose. To spend from a script, you need to create a valid transaction and sign it. Nothing is stopping you from creating and signing that transaction outside of Armory. The private keys are in your control the whole time, that's what matters in the end.

It is true that if you are not technical and wish to withdraw coins from an Armory specific script type on whatever air drop fork, you would have to wait for someone else to make that code available to you. If you're aggressively after the airdrops, I suggest you stick to legacy P2PKH, as it is the most widely accepted script type.
newbie
Activity: 3
Merit: 0
Does it mean that by using an P2SH-P2PK address I indissolubly and irrecoverably bound my chances to recover forked funds to the fate of Armory?

No way to do this via methods similar to what is described here https://www.reddit.com/r/BitcoinAirdrops/comments/7io9d4/guide_retrieving_bitcoin_gold_from_segwit_address/ or here https://bitcointalksearch.org/topic/m.27503623?
legendary
Activity: 3794
Merit: 1375
Armory Developer
You're thinking of P2SH-P2WPKH

Whoops, that's right.
staff
Activity: 3458
Merit: 6793
Just writing some code
No, there is not. P2SH-P2PK is an Armory specific script type.

Should be, this script format is described in the SW BIPs after all.
You're thinking of P2SH-P2WPKH
legendary
Activity: 3794
Merit: 1375
Armory Developer
Should be, this script format is described in the SW BIPs after all.
newbie
Activity: 3
Merit: 0
Hi,

I'd like to copy an address from my Armory wallet, displayed under the section P2SH-P2PK, to a Bitcoin Core wallet, along with the key required to sign a payment. Is this possible? If not, are there any wallets that are able to digest Armory's data to that end?

Thank you very much in advance!

Kora
Jump to: