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:
version (4 bytes)
TxIn count (varint)
TxIns
TxOut count (varint)
TxOuts
LockTime (4 bytes)
TxIns looks like this:
Outpoint (32bytes txhash + 4bytes txout index)
scriptsig
sequence (4bytes)
And TxOuts look like this:
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:
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#L2673So the scriptSig would look like this:
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.