diff options
| author | Glenn Willen <[email protected]> | 2019-01-09 03:08:32 -0800 |
|---|---|---|
| committer | Glenn Willen <[email protected]> | 2019-02-11 14:08:04 -0800 |
| commit | 102faad81efa1cb12c29c466cfe81fc8c7351e1d (patch) | |
| tree | 7353c37cc34161eb350e41cac2f1a7e1e8b8ee23 /src/psbt.h | |
| parent | Remove op== on PSBTs; check compatibility in Merge (diff) | |
| download | discoin-102faad81efa1cb12c29c466cfe81fc8c7351e1d.tar.xz discoin-102faad81efa1cb12c29c466cfe81fc8c7351e1d.zip | |
Factor out combine / finalize / extract PSBT helpers
Refactor the new CombinePSBT, FinalizePSBT, and FinalizeAndExtractPSBT
general-purpose functions out of the combinepsbt and finalizepsbt RPCs,
for use in the GUI code.
Diffstat (limited to 'src/psbt.h')
| -rw-r--r-- | src/psbt.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/psbt.h b/src/psbt.h index 4b7ea4383..e18790322 100644 --- a/src/psbt.h +++ b/src/psbt.h @@ -544,4 +544,31 @@ bool PSBTInputSigned(PSBTInput& input); /** Signs a PSBTInput, verifying that all provided data matches what is being signed. */ bool SignPSBTInput(const SigningProvider& provider, PartiallySignedTransaction& psbt, int index, int sighash = SIGHASH_ALL); +/** + * Finalizes a PSBT if possible, combining partial signatures. + * + * @param[in,out] &psbtx reference to PartiallySignedTransaction to finalize + * return True if the PSBT is now complete, false otherwise + */ +bool FinalizePSBT(PartiallySignedTransaction& psbtx); + +/** + * Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized. + * + * @param[in] &psbtx reference to PartiallySignedTransaction + * @param[out] result CMutableTransaction representing the complete transaction, if successful + * @return True if we successfully extracted the transaction, false otherwise + */ +bool FinalizeAndExtractPSBT(PartiallySignedTransaction& psbtx, CMutableTransaction& result); + +/** + * Combines PSBTs with the same underlying transaction, resulting in a single PSBT with all partial signatures from each input. + * + * @param[out] &out the combined PSBT, if successful + * @param[out] &error reference to TransactionError to fill with error info on failure + * @param[in] psbtxs the PSBTs to combine + * @return True if we successfully combined the transactions, false if they were not compatible + */ +bool CombinePSBTs(PartiallySignedTransaction& out, TransactionError& error, const std::vector<PartiallySignedTransaction>& psbtxs); + #endif // BITCOIN_PSBT_H |