New PartiallySignedTransaction constructor from CTransction

New constructor that creates a PartiallySignedTransaction from a
CTransaction, automatically sizing the inputs and outputs vectors for
convenience.
This commit is contained in:
Glenn Willen 2018-10-26 15:26:16 -07:00
parent 4f3f5cb4b1
commit 65166d4cf8
3 changed files with 8 additions and 8 deletions

View file

@ -513,6 +513,12 @@ bool IsSolvable(const SigningProvider& provider, const CScript& script)
return false; return false;
} }
PartiallySignedTransaction::PartiallySignedTransaction(const CTransaction& tx) : tx(tx)
{
inputs.resize(tx.vin.size());
outputs.resize(tx.vout.size());
}
bool PartiallySignedTransaction::IsNull() const bool PartiallySignedTransaction::IsNull() const
{ {
return !tx && inputs.empty() && outputs.empty() && unknown.empty(); return !tx && inputs.empty() && outputs.empty() && unknown.empty();

View file

@ -566,6 +566,7 @@ struct PartiallySignedTransaction
bool IsSane() const; bool IsSane() const;
PartiallySignedTransaction() {} PartiallySignedTransaction() {}
PartiallySignedTransaction(const PartiallySignedTransaction& psbt_in) : tx(psbt_in.tx), inputs(psbt_in.inputs), outputs(psbt_in.outputs), unknown(psbt_in.unknown) {} PartiallySignedTransaction(const PartiallySignedTransaction& psbt_in) : tx(psbt_in.tx), inputs(psbt_in.inputs), outputs(psbt_in.outputs), unknown(psbt_in.unknown) {}
explicit PartiallySignedTransaction(const CTransaction& tx);
// Only checks if they refer to the same transaction // Only checks if they refer to the same transaction
friend bool operator==(const PartiallySignedTransaction& a, const PartiallySignedTransaction &b) friend bool operator==(const PartiallySignedTransaction& a, const PartiallySignedTransaction &b)

View file

@ -3930,14 +3930,7 @@ UniValue walletcreatefundedpsbt(const JSONRPCRequest& request)
FundTransaction(pwallet, rawTx, fee, change_position, request.params[3]); FundTransaction(pwallet, rawTx, fee, change_position, request.params[3]);
// Make a blank psbt // Make a blank psbt
PartiallySignedTransaction psbtx; PartiallySignedTransaction psbtx(rawTx);
psbtx.tx = rawTx;
for (unsigned int i = 0; i < rawTx.vin.size(); ++i) {
psbtx.inputs.push_back(PSBTInput());
}
for (unsigned int i = 0; i < rawTx.vout.size(); ++i) {
psbtx.outputs.push_back(PSBTOutput());
}
// Fill transaction with out data but don't sign // Fill transaction with out data but don't sign
bool bip32derivs = request.params[4].isNull() ? false : request.params[4].get_bool(); bool bip32derivs = request.params[4].isNull() ? false : request.params[4].get_bool();