Bitcoin Core 28.99.0
P2P Digital Currency
transaction_utils.h
Go to the documentation of this file.
1// Copyright (c) 2019-2020 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_TEST_UTIL_TRANSACTION_UTILS_H
6#define BITCOIN_TEST_UTIL_TRANSACTION_UTILS_H
7
9#include <script/sign.h>
10
11#include <array>
12
14class CCoinsViewCache;
15
16// create crediting transaction
17// [1 coinbase input => 1 output with given scriptPubkey and value]
18CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey, int nValue = 0);
19
20// create spending transaction
21// [1 input with referenced transaction outpoint, scriptSig, scriptWitness =>
22// 1 output with empty scriptPubKey, full value of referenced transaction]
23CMutableTransaction BuildSpendingTransaction(const CScript& scriptSig, const CScriptWitness& scriptWitness, const CTransaction& txCredit);
24
25// Helper: create two dummy transactions, each with two outputs.
26// The first has nValues[0] and nValues[1] outputs paid to a TxoutType::PUBKEY,
27// the second nValues[2] and nValues[3] outputs paid to a TxoutType::PUBKEYHASH.
28std::vector<CMutableTransaction> SetupDummyInputs(FillableSigningProvider& keystoreRet, CCoinsViewCache& coinsRet, const std::array<CAmount,4>& nValues);
29
30// bulk transaction to reach a certain target weight,
31// by appending a single output with padded output script
32void BulkTransaction(CMutableTransaction& tx, int32_t target_weight);
33
48bool SignSignature(const SigningProvider &provider, const CScript& fromPubKey, CMutableTransaction& txTo,
49 unsigned int nIn, const CAmount& amount, int nHashType, SignatureData& sig_data);
50bool SignSignature(const SigningProvider &provider, const CTransaction& txFrom, CMutableTransaction& txTo,
51 unsigned int nIn, int nHashType, SignatureData& sig_data);
52
53#endif // BITCOIN_TEST_UTIL_TRANSACTION_UTILS_H
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:363
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:415
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:296
Fillable signing provider that keeps keys in an address->secret map.
An interface to be implemented by keystores that support signing.
A mutable version of CTransaction.
Definition: transaction.h:378
CMutableTransaction BuildSpendingTransaction(const CScript &scriptSig, const CScriptWitness &scriptWitness, const CTransaction &txCredit)
void BulkTransaction(CMutableTransaction &tx, int32_t target_weight)
CMutableTransaction BuildCreditingTransaction(const CScript &scriptPubKey, int nValue=0)
std::vector< CMutableTransaction > SetupDummyInputs(FillableSigningProvider &keystoreRet, CCoinsViewCache &coinsRet, const std::array< CAmount, 4 > &nValues)
bool SignSignature(const SigningProvider &provider, const CScript &fromPubKey, CMutableTransaction &txTo, unsigned int nIn, const CAmount &amount, int nHashType, SignatureData &sig_data)
Produce a satisfying script (scriptSig or witness).