Changeset View
Changeset View
Standalone View
Standalone View
src/test/script_tests.cpp
Show First 20 Lines • Show All 2,724 Lines • ▼ Show 20 Lines | for (int i = 0; i < 3; i++) { | ||||
CKey key; | CKey key; | ||||
key.MakeNewKey(i % 2 == 1); | key.MakeNewKey(i % 2 == 1); | ||||
keys.push_back(key); | keys.push_back(key); | ||||
pubkeys.push_back(key.GetPubKey()); | pubkeys.push_back(key.GetPubKey()); | ||||
keystore.AddKey(key); | keystore.AddKey(key); | ||||
} | } | ||||
CMutableTransaction txFrom = BuildCreditingTransaction( | CMutableTransaction txFrom = BuildCreditingTransaction( | ||||
GetScriptForDestination(keys[0].GetPubKey().GetID()), Amount::zero()); | GetScriptForDestination(PKHash(keys[0].GetPubKey())), Amount::zero()); | ||||
CMutableTransaction txTo = | CMutableTransaction txTo = | ||||
BuildSpendingTransaction(CScript(), CTransaction(txFrom)); | BuildSpendingTransaction(CScript(), CTransaction(txFrom)); | ||||
CScript &scriptPubKey = txFrom.vout[0].scriptPubKey; | CScript &scriptPubKey = txFrom.vout[0].scriptPubKey; | ||||
SignatureData scriptSig; | SignatureData scriptSig; | ||||
SignatureData empty; | SignatureData empty; | ||||
SignatureData combined = | SignatureData combined = | ||||
CombineSignatures(txFrom.vout[0], txTo, empty, empty); | CombineSignatures(txFrom.vout[0], txTo, empty, empty); | ||||
Show All 16 Lines | combined = | ||||
CombineSignatures(txFrom.vout[0], txTo, scriptSigCopy, scriptSig); | CombineSignatures(txFrom.vout[0], txTo, scriptSigCopy, scriptSig); | ||||
BOOST_CHECK(combined.scriptSig == scriptSigCopy.scriptSig || | BOOST_CHECK(combined.scriptSig == scriptSigCopy.scriptSig || | ||||
combined.scriptSig == scriptSig.scriptSig); | combined.scriptSig == scriptSig.scriptSig); | ||||
// P2SH, single-signature case: | // P2SH, single-signature case: | ||||
CScript pkSingle; | CScript pkSingle; | ||||
pkSingle << ToByteVector(keys[0].GetPubKey()) << OP_CHECKSIG; | pkSingle << ToByteVector(keys[0].GetPubKey()) << OP_CHECKSIG; | ||||
keystore.AddCScript(pkSingle); | keystore.AddCScript(pkSingle); | ||||
scriptPubKey = GetScriptForDestination(CScriptID(pkSingle)); | scriptPubKey = GetScriptForDestination(ScriptHash(pkSingle)); | ||||
SignSignature(keystore, CTransaction(txFrom), txTo, 0, | SignSignature(keystore, CTransaction(txFrom), txTo, 0, | ||||
SigHashType().withForkId()); | SigHashType().withForkId()); | ||||
scriptSig = DataFromTransaction(txTo, 0, txFrom.vout[0]); | scriptSig = DataFromTransaction(txTo, 0, txFrom.vout[0]); | ||||
combined = CombineSignatures(txFrom.vout[0], txTo, scriptSig, empty); | combined = CombineSignatures(txFrom.vout[0], txTo, scriptSig, empty); | ||||
BOOST_CHECK(combined.scriptSig == scriptSig.scriptSig); | BOOST_CHECK(combined.scriptSig == scriptSig.scriptSig); | ||||
combined = CombineSignatures(txFrom.vout[0], txTo, empty, scriptSig); | combined = CombineSignatures(txFrom.vout[0], txTo, empty, scriptSig); | ||||
BOOST_CHECK(combined.scriptSig == scriptSig.scriptSig); | BOOST_CHECK(combined.scriptSig == scriptSig.scriptSig); | ||||
scriptSigCopy = scriptSig; | scriptSigCopy = scriptSig; | ||||
▲ Show 20 Lines • Show All 456 Lines • Show Last 20 Lines |