Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show First 20 Lines • Show All 1,544 Lines • ▼ Show 20 Lines | static UniValue combinepsbt(const Config &config, | ||||
PartiallySignedTransaction merged_psbt; | PartiallySignedTransaction merged_psbt; | ||||
const TransactionError error = CombinePSBTs(merged_psbt, psbtxs); | const TransactionError error = CombinePSBTs(merged_psbt, psbtxs); | ||||
if (error != TransactionError::OK) { | if (error != TransactionError::OK) { | ||||
throw JSONRPCTransactionError(error); | throw JSONRPCTransactionError(error); | ||||
} | } | ||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | ||||
ssTx << merged_psbt; | ssTx << merged_psbt; | ||||
return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | return EncodeBase64(MakeUCharSpan(ssTx)); | ||||
} | } | ||||
static UniValue finalizepsbt(const Config &config, | static UniValue finalizepsbt(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"finalizepsbt", | "finalizepsbt", | ||||
"Finalize the inputs of a PSBT. If the transaction is fully signed, it " | "Finalize the inputs of a PSBT. If the transaction is fully signed, it " | ||||
"will produce a\n" | "will produce a\n" | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | static UniValue createpsbt(const Config &config, | ||||
for (size_t i = 0; i < rawTx.vout.size(); ++i) { | for (size_t i = 0; i < rawTx.vout.size(); ++i) { | ||||
psbtx.outputs.push_back(PSBTOutput()); | psbtx.outputs.push_back(PSBTOutput()); | ||||
} | } | ||||
// Serialize the PSBT | // Serialize the PSBT | ||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | ||||
ssTx << psbtx; | ssTx << psbtx; | ||||
return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | return EncodeBase64(MakeUCharSpan(ssTx)); | ||||
} | } | ||||
static UniValue converttopsbt(const Config &config, | static UniValue converttopsbt(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"converttopsbt", | "converttopsbt", | ||||
"Converts a network serialized transaction to a PSBT. " | "Converts a network serialized transaction to a PSBT. " | ||||
"This should be used only with createrawtransaction and " | "This should be used only with createrawtransaction and " | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | static UniValue converttopsbt(const Config &config, | ||||
for (size_t i = 0; i < tx.vout.size(); ++i) { | for (size_t i = 0; i < tx.vout.size(); ++i) { | ||||
psbtx.outputs.push_back(PSBTOutput()); | psbtx.outputs.push_back(PSBTOutput()); | ||||
} | } | ||||
// Serialize the PSBT | // Serialize the PSBT | ||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | ||||
ssTx << psbtx; | ssTx << psbtx; | ||||
return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | return EncodeBase64(MakeUCharSpan(ssTx)); | ||||
} | } | ||||
UniValue utxoupdatepsbt(const Config &config, const JSONRPCRequest &request) { | UniValue utxoupdatepsbt(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"utxoupdatepsbt", | "utxoupdatepsbt", | ||||
"Updates all inputs and outputs in a PSBT with data from output " | "Updates all inputs and outputs in a PSBT with data from output " | ||||
"descriptors, the UTXO set or the mempool.\n", | "descriptors, the UTXO set or the mempool.\n", | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | UniValue utxoupdatepsbt(const Config &config, const JSONRPCRequest &request) { | ||||
// Update script/keypath information using descriptor data. | // Update script/keypath information using descriptor data. | ||||
for (unsigned int i = 0; i < psbtx.tx->vout.size(); ++i) { | for (unsigned int i = 0; i < psbtx.tx->vout.size(); ++i) { | ||||
UpdatePSBTOutput(public_provider, psbtx, i); | UpdatePSBTOutput(public_provider, psbtx, i); | ||||
} | } | ||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | ||||
ssTx << psbtx; | ssTx << psbtx; | ||||
return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | return EncodeBase64(MakeUCharSpan(ssTx)); | ||||
} | } | ||||
UniValue joinpsbts(const Config &config, const JSONRPCRequest &request) { | UniValue joinpsbts(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"joinpsbts", | "joinpsbts", | ||||
"Joins multiple distinct PSBTs with different inputs and outputs " | "Joins multiple distinct PSBTs with different inputs and outputs " | ||||
"into one PSBT with inputs and outputs from all of the PSBTs\n" | "into one PSBT with inputs and outputs from all of the PSBTs\n" | ||||
"No input in any of the PSBTs can be in more than one of the PSBTs.\n", | "No input in any of the PSBTs can be in more than one of the PSBTs.\n", | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | for (int i : output_indices) { | ||||
shuffled_psbt.AddOutput(merged_psbt.tx->vout[i], | shuffled_psbt.AddOutput(merged_psbt.tx->vout[i], | ||||
merged_psbt.outputs[i]); | merged_psbt.outputs[i]); | ||||
} | } | ||||
shuffled_psbt.unknown.insert(merged_psbt.unknown.begin(), | shuffled_psbt.unknown.insert(merged_psbt.unknown.begin(), | ||||
merged_psbt.unknown.end()); | merged_psbt.unknown.end()); | ||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); | ||||
ssTx << shuffled_psbt; | ssTx << shuffled_psbt; | ||||
return EncodeBase64((uint8_t *)ssTx.data(), ssTx.size()); | return EncodeBase64(MakeUCharSpan(ssTx)); | ||||
} | } | ||||
UniValue analyzepsbt(const Config &config, const JSONRPCRequest &request) { | UniValue analyzepsbt(const Config &config, const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"analyzepsbt", | "analyzepsbt", | ||||
"Analyzes and provides information about the current status of a " | "Analyzes and provides information about the current status of a " | ||||
"PSBT and its inputs\n", | "PSBT and its inputs\n", | ||||
{{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, | {{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
▲ Show 20 Lines • Show All 167 Lines • Show Last 20 Lines |