Created
October 11, 2017 16:59
-
-
Save Christewart/3d930327e7b27e6a897fa6d2744ec569 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CScript redeemScript = std::get<0>(spk_keys); | |
const std::vector<CKey> keys = std::get<1>(spk_keys); | |
//hash the spk | |
const CScript p2sh = GetScriptForDestination(CScriptID(redeemScript)); | |
//return sign(std::make_tuple(p2sh,keys)); | |
const int inputIndex = 0; | |
//const CScript spk = std::get<0>(spk_keys); | |
//const std::vector<CKey> keys = std::get<1>(spk_keys); | |
CBasicKeyStore store; | |
for (const auto k: keys) { | |
store.AddKey(k); | |
} | |
//add redeem script | |
store.AddCScript(redeemScript); | |
CMutableTransaction creditingTx = BuildCreditingTransaction(p2sh); | |
CMutableTransaction spendingTx = BuildSpendingTransaction(CScript(), CScriptWitness(), creditingTx); | |
CTransaction spendingTxConst(spendingTx); | |
SignatureData sigdata; | |
TransactionSignatureCreator creator(&store,&spendingTxConst,inputIndex,0); | |
assert(ProduceSignature(creator, p2sh, sigdata)); | |
UpdateTransaction(spendingTx,0,sigdata); | |
const CTxOut output(0,p2sh); | |
const CTransaction finalTx = CTransaction(spendingTx); | |
SpendingInfo tup = std::make_tuple(output,finalTx,inputIndex); | |
return tup; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment