Changeset View
Changeset View
Standalone View
Standalone View
src/node/psbt.cpp
// Copyright (c) 2009-2018 The Bitcoin Core developers | // Copyright (c) 2009-2018 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <coins.h> | #include <coins.h> | ||||
#include <consensus/tx_verify.h> | #include <consensus/tx_verify.h> | ||||
#include <node/psbt.h> | #include <node/psbt.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
#include <policy/settings.h> | #include <policy/settings.h> | ||||
#include <tinyformat.h> | |||||
#include <numeric> | #include <numeric> | ||||
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx) { | PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx) { | ||||
// Go through each input and build status | // Go through each input and build status | ||||
PSBTAnalysis result; | PSBTAnalysis result; | ||||
bool calc_fee = true; | bool calc_fee = true; | ||||
Show All 15 Lines | for (size_t i = 0; i < psbtx.tx->vin.size(); ++i) { | ||||
input_analysis.has_utxo = true; | input_analysis.has_utxo = true; | ||||
} else { | } else { | ||||
input_analysis.has_utxo = false; | input_analysis.has_utxo = false; | ||||
input_analysis.is_final = false; | input_analysis.is_final = false; | ||||
input_analysis.next = PSBTRole::UPDATER; | input_analysis.next = PSBTRole::UPDATER; | ||||
calc_fee = false; | calc_fee = false; | ||||
} | } | ||||
if (!utxo.IsNull() && utxo.scriptPubKey.IsUnspendable()) { | |||||
result.SetInvalid(strprintf( | |||||
"PSBT is not valid. Input %u spends unspendable output", i)); | |||||
return result; | |||||
} | |||||
// Check if it is final | // Check if it is final | ||||
if (!utxo.IsNull() && !PSBTInputSigned(input)) { | if (!utxo.IsNull() && !PSBTInputSigned(input)) { | ||||
input_analysis.is_final = false; | input_analysis.is_final = false; | ||||
all_final = false; | all_final = false; | ||||
// Figure out what is missing | // Figure out what is missing | ||||
SignatureData outdata; | SignatureData outdata; | ||||
bool complete = SignPSBTInput(DUMMY_SIGNING_PROVIDER, psbtx, i, | bool complete = SignPSBTInput(DUMMY_SIGNING_PROVIDER, psbtx, i, | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |