2019-10-18 02:05:05 +02:00
|
|
|
// Copyright (c) 2019 The Bitcoin Core developers
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2019-11-05 15:18:59 -05:00
|
|
|
#include <test/util/transaction_utils.h>
|
2019-10-18 02:05:05 +02:00
|
|
|
|
|
|
|
CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey, int nValue)
|
|
|
|
{
|
|
|
|
CMutableTransaction txCredit;
|
|
|
|
txCredit.nVersion = 1;
|
|
|
|
txCredit.nLockTime = 0;
|
|
|
|
txCredit.vin.resize(1);
|
|
|
|
txCredit.vout.resize(1);
|
|
|
|
txCredit.vin[0].prevout.SetNull();
|
|
|
|
txCredit.vin[0].scriptSig = CScript() << CScriptNum(0) << CScriptNum(0);
|
|
|
|
txCredit.vin[0].nSequence = CTxIn::SEQUENCE_FINAL;
|
|
|
|
txCredit.vout[0].scriptPubKey = scriptPubKey;
|
|
|
|
txCredit.vout[0].nValue = nValue;
|
|
|
|
|
|
|
|
return txCredit;
|
|
|
|
}
|
|
|
|
|
|
|
|
CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CScriptWitness& scriptWitness, const CTransaction& txCredit)
|
|
|
|
{
|
|
|
|
CMutableTransaction txSpend;
|
|
|
|
txSpend.nVersion = 1;
|
|
|
|
txSpend.nLockTime = 0;
|
|
|
|
txSpend.vin.resize(1);
|
|
|
|
txSpend.vout.resize(1);
|
|
|
|
txSpend.vin[0].scriptWitness = scriptWitness;
|
|
|
|
txSpend.vin[0].prevout.hash = txCredit.GetHash();
|
|
|
|
txSpend.vin[0].prevout.n = 0;
|
|
|
|
txSpend.vin[0].scriptSig = scriptSig;
|
|
|
|
txSpend.vin[0].nSequence = CTxIn::SEQUENCE_FINAL;
|
|
|
|
txSpend.vout[0].scriptPubKey = CScript();
|
|
|
|
txSpend.vout[0].nValue = txCredit.vout[0].nValue;
|
|
|
|
|
|
|
|
return txSpend;
|
|
|
|
}
|