Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show All 12 Lines | |||||
#include <key_io.h> | #include <key_io.h> | ||||
#include <merkleblock.h> | #include <merkleblock.h> | ||||
#include <node/coin.h> | #include <node/coin.h> | ||||
#include <node/context.h> | #include <node/context.h> | ||||
#include <node/psbt.h> | #include <node/psbt.h> | ||||
#include <node/transaction.h> | #include <node/transaction.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <psbt.h> | #include <psbt.h> | ||||
#include <random.h> | |||||
#include <rpc/blockchain.h> | #include <rpc/blockchain.h> | ||||
#include <rpc/rawtransaction_util.h> | #include <rpc/rawtransaction_util.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <rpc/util.h> | #include <rpc/util.h> | ||||
#include <script/script.h> | #include <script/script.h> | ||||
#include <script/sign.h> | #include <script/sign.h> | ||||
#include <script/signingprovider.h> | #include <script/signingprovider.h> | ||||
#include <script/standard.h> | #include <script/standard.h> | ||||
#include <txmempool.h> | #include <txmempool.h> | ||||
#include <uint256.h> | #include <uint256.h> | ||||
#include <util/error.h> | #include <util/error.h> | ||||
#include <util/moneystr.h> | #include <util/moneystr.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <validationinterface.h> | #include <validationinterface.h> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <numeric> | |||||
#include <univalue.h> | #include <univalue.h> | ||||
/** | /** | ||||
* High fee for sendrawtransaction and testmempoolaccept. | * High fee for sendrawtransaction and testmempoolaccept. | ||||
* By default, transaction with a fee higher than this will be rejected by the | * By default, transaction with a fee higher than this will be rejected by the | ||||
* RPCs. This can be overridden with the maxfeerate argument. | * RPCs. This can be overridden with the maxfeerate argument. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 1,729 Lines • ▼ Show 20 Lines | for (auto &psbt : psbtxs) { | ||||
} | } | ||||
} | } | ||||
for (size_t i = 0; i < psbt.tx->vout.size(); ++i) { | for (size_t i = 0; i < psbt.tx->vout.size(); ++i) { | ||||
merged_psbt.AddOutput(psbt.tx->vout[i], psbt.outputs[i]); | merged_psbt.AddOutput(psbt.tx->vout[i], psbt.outputs[i]); | ||||
} | } | ||||
merged_psbt.unknown.insert(psbt.unknown.begin(), psbt.unknown.end()); | merged_psbt.unknown.insert(psbt.unknown.begin(), psbt.unknown.end()); | ||||
} | } | ||||
// Generate list of shuffled indices for shuffling inputs and outputs of the | |||||
// merged PSBT | |||||
std::vector<int> input_indices(merged_psbt.inputs.size()); | |||||
std::iota(input_indices.begin(), input_indices.end(), 0); | |||||
std::vector<int> output_indices(merged_psbt.outputs.size()); | |||||
std::iota(output_indices.begin(), output_indices.end(), 0); | |||||
// Shuffle input and output indicies lists | |||||
Shuffle(input_indices.begin(), input_indices.end(), FastRandomContext()); | |||||
Shuffle(output_indices.begin(), output_indices.end(), FastRandomContext()); | |||||
PartiallySignedTransaction shuffled_psbt; | |||||
shuffled_psbt.tx = CMutableTransaction(); | |||||
shuffled_psbt.tx->nVersion = merged_psbt.tx->nVersion; | |||||
shuffled_psbt.tx->nLockTime = merged_psbt.tx->nLockTime; | |||||
for (int i : input_indices) { | |||||
shuffled_psbt.AddInput(merged_psbt.tx->vin[i], merged_psbt.inputs[i]); | |||||
} | |||||
for (int i : output_indices) { | |||||
shuffled_psbt.AddOutput(merged_psbt.tx->vout[i], | |||||
merged_psbt.outputs[i]); | |||||
} | |||||
shuffled_psbt.unknown.insert(merged_psbt.unknown.begin(), | |||||
merged_psbt.unknown.end()); | |||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | ||||
ssTx << merged_psbt; | ssTx << shuffled_psbt; | ||||
return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | ||||
} | } | ||||
UniValue analyzepsbt(const Config &config, const JSONRPCRequest &request) { | UniValue analyzepsbt(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"analyzepsbt", | "analyzepsbt", | ||||
"\nAnalyzes and provides information about the current status of a " | "\nAnalyzes and provides information about the current status of a " | ||||
"PSBT and its inputs\n", | "PSBT and its inputs\n", | ||||
▲ Show 20 Lines • Show All 136 Lines • Show Last 20 Lines |