Bitcoin Forum
May 30, 2024, 01:47:09 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Is the transfer of a P2SH-P2PK address+key to Bitcoin Core doable?  (Read 247 times)
koranucci (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
December 17, 2017, 10:10:53 PM
 #1

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
goatpig
Moderator
Legendary
*
Offline Offline

Activity: 3668
Merit: 1347

Armory Developer


View Profile
December 17, 2017, 11:36:02 PM
 #2

Should be, this script format is described in the SW BIPs after all.

achow101
Staff
Legendary
*
Offline Offline

Activity: 3402
Merit: 6659


Just writing some code


View Profile WWW
December 18, 2017, 12:35:43 AM
 #3

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

goatpig
Moderator
Legendary
*
Offline Offline

Activity: 3668
Merit: 1347

Armory Developer


View Profile
December 18, 2017, 12:42:46 AM
 #4

You're thinking of P2SH-P2WPKH

Whoops, that's right.

koranucci (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
January 05, 2018, 08:34:01 AM
 #5

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://bitcointalk.org/index.php?topic=2689834.msg27503623#msg27503623?
goatpig
Moderator
Legendary
*
Offline Offline

Activity: 3668
Merit: 1347

Armory Developer


View Profile
January 05, 2018, 09:34:32 AM
 #6

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.

koranucci (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
January 05, 2018, 03:03:28 PM
 #7

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!
bk1041
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
January 06, 2018, 04:40:45 PM
Last edit: January 06, 2018, 05:12:19 PM by bk1041
 #8

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!
bk1041
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
January 09, 2018, 01:54:32 AM
 #9


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!
goatpig
Moderator
Legendary
*
Offline Offline

Activity: 3668
Merit: 1347

Armory Developer


View Profile
January 09, 2018, 02:11:24 PM
 #10

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.

bk1041
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
January 11, 2018, 09:26:22 AM
 #11

@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.

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!