| 735 | } |
| 736 | |
| 737 | bool FinalizeAndExtractPSBT(PartiallySignedTransaction& psbtx, CMutableTransaction& result) |
| 738 | { |
| 739 | // It's not safe to extract a PSBT that isn't finalized, and there's no easy way to check |
| 740 | // whether a PSBT is finalized without finalizing it, so we just do this. |
| 741 | if (!FinalizePSBT(psbtx)) { |
| 742 | return false; |
| 743 | } |
| 744 | |
| 745 | result = psbtx.GetUnsignedTx(); |
| 746 | for (unsigned int i = 0; i < result.vin.size(); ++i) { |
| 747 | const PSBTInput& psbt_in = psbtx.inputs[i]; |
| 748 | CTxIn& txin = result.vin[i]; |
| 749 | CTxInWitness& txin_wit = result.witness.vtxinwit[i]; |
| 750 | |
| 751 | txin.scriptSig = psbt_in.final_script_sig; |
| 752 | txin_wit.scriptWitness = psbt_in.final_script_witness; |
| 753 | txin_wit.vchIssuanceAmountRangeproof = psbt_in.m_issuance_rangeproof; |
| 754 | txin_wit.vchInflationKeysRangeproof = psbt_in.m_issuance_inflation_keys_rangeproof; |
| 755 | |
| 756 | txin.m_is_pegin = !psbt_in.m_peg_in_witness.IsNull(); |
| 757 | txin_wit.m_pegin_witness = psbt_in.m_peg_in_witness; |
| 758 | } |
| 759 | for (unsigned int i = 0; i < result.vout.size(); ++i) { |
| 760 | const PSBTOutput& psbt_out = psbtx.outputs[i]; |
| 761 | result.witness.vtxoutwit[i].vchSurjectionproof = psbt_out.m_asset_surjection_proof; |
| 762 | result.witness.vtxoutwit[i].vchRangeproof = psbt_out.m_value_rangeproof; |
| 763 | } |
| 764 | return true; |
| 765 | } |
| 766 | |
| 767 | TransactionError CombinePSBTs(PartiallySignedTransaction& out, const std::vector<PartiallySignedTransaction>& psbtxs) |
| 768 | { |