Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2019-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_TEST_UTIL_TRANSACTION_UTILS_H6#define BITCOIN_TEST_UTIL_TRANSACTION_UTILS_H8#include <primitives/transaction.h>9#include <script/sign.h>11#include <array>13class FillableSigningProvider;14class CCoinsViewCache;16// create crediting transaction17// [1 coinbase input => 1 output with given scriptPubkey and value]18CMutableTransaction BuildCreditingTransaction(const CScript& scriptPubKey, CAmount nValue = 0);20// create spending transaction21// [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);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);30// bulk transaction to reach a certain target weight,31// by appending a single output with padded output script32void BulkTransaction(CMutableTransaction& tx, int32_t target_weight);34/**35* Produce a satisfying script (scriptSig or witness).36*37* @param provider Utility containing the information necessary to solve a script.38* @param fromPubKey The script to produce a satisfaction for.39* @param txTo The spending transaction.40* @param nIn The index of the input in `txTo` referring the output being spent.41* @param amount The value of the output being spent.42* @param nHashType Signature hash type.43* @param sig_data Additional data provided to solve a script. Filled with the resulting satisfying44* script and whether the satisfaction is complete.45*46* @return True if the produced script is entirely satisfying `fromPubKey`.47**/48bool SignSignature(const SigningProvider &provider, const CScript& fromPubKey, CMutableTransaction& txTo,49unsigned int nIn, const CAmount& amount, int nHashType, SignatureData& sig_data);50bool SignSignature(const SigningProvider &provider, const CTransaction& txFrom, CMutableTransaction& txTo,51unsigned int nIn, int nHashType, SignatureData& sig_data);53#endif // BITCOIN_TEST_UTIL_TRANSACTION_UTILS_H
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.