Skip to content

Commit

Permalink
New PartiallySignedTransaction constructor from CTransction
Browse files Browse the repository at this point in the history
New constructor that creates a PartiallySignedTransaction from a
CTransaction, automatically sizing the inputs and outputs vectors for
convenience.
  • Loading branch information
gwillen committed Nov 1, 2018
1 parent 4f3f5cb commit 65166d4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/script/sign.cpp
Expand Up @@ -513,6 +513,12 @@ bool IsSolvable(const SigningProvider& provider, const CScript& script)
return false;
}

PartiallySignedTransaction::PartiallySignedTransaction(const CTransaction& tx) : tx(tx)
{
inputs.resize(tx.vin.size());
outputs.resize(tx.vout.size());
}

bool PartiallySignedTransaction::IsNull() const
{
return !tx && inputs.empty() && outputs.empty() && unknown.empty();
Expand Down
1 change: 1 addition & 0 deletions src/script/sign.h
Expand Up @@ -566,6 +566,7 @@ struct PartiallySignedTransaction
bool IsSane() const;
PartiallySignedTransaction() {}
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
friend bool operator==(const PartiallySignedTransaction& a, const PartiallySignedTransaction &b)
Expand Down
9 changes: 1 addition & 8 deletions src/wallet/rpcwallet.cpp
Expand Up @@ -3930,14 +3930,7 @@ UniValue walletcreatefundedpsbt(const JSONRPCRequest& request)
FundTransaction(pwallet, rawTx, fee, change_position, request.params[3]);

// Make a blank psbt
PartiallySignedTransaction psbtx;
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());
}
PartiallySignedTransaction psbtx(rawTx);

// Fill transaction with out data but don't sign
bool bip32derivs = request.params[4].isNull() ? false : request.params[4].get_bool();
Expand Down

0 comments on commit 65166d4

Please sign in to comment.