mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Merge psbt peg-in data
This commit is contained in:
parent
4ad849fed2
commit
73711eb0bb
2 changed files with 14 additions and 0 deletions
|
|
@ -159,6 +159,11 @@ void PSBTInput::Merge(const PSBTInput& input)
|
|||
if (value_blinding_factor.IsNull() && !input.value_blinding_factor.IsNull()) value_blinding_factor = input.value_blinding_factor;
|
||||
if (asset.IsNull() && !input.asset.IsNull()) asset = input.asset;
|
||||
if (asset_blinding_factor.IsNull() && !input.asset_blinding_factor.IsNull()) asset_blinding_factor = input.asset_blinding_factor;
|
||||
|
||||
if (peg_in_tx.which() == 0 && peg_in_tx.which() > 0) peg_in_tx = input.peg_in_tx;
|
||||
if (txout_proof.which() == 0 && peg_in_tx.which() > 0) txout_proof = input.txout_proof;
|
||||
if (claim_script.empty() && !input.claim_script.empty()) claim_script = input.claim_script;
|
||||
if (genesis_hash.IsNull() && !input.genesis_hash.IsNull()) genesis_hash = input.genesis_hash;
|
||||
}
|
||||
|
||||
bool PSBTInput::IsSane() const
|
||||
|
|
|
|||
|
|
@ -302,6 +302,15 @@ class FedPegTest(BitcoinTestFramework):
|
|||
assert_equal(decoded_psbt['inputs'][0]['pegin_claim_script'], addrs["claim_script"])
|
||||
assert_equal(decoded_psbt['inputs'][0]['pegin_txout_proof'], proof)
|
||||
assert_equal(decoded_psbt['inputs'][0]['pegin_genesis_hash'], parent.getblockhash(0))
|
||||
# Make a psbt without those peg-in data and merge them
|
||||
merge_pegin_psbt = sidechain.createpsbt([{"txid":txid1, "vout": vout}], outputs)
|
||||
decoded_psbt = sidechain.decodepsbt(merge_pegin_psbt)
|
||||
assert 'pegin_bitcoin_tx' not in decoded_psbt['inputs'][0]
|
||||
assert 'pegin_claim_script' not in decoded_psbt['inputs'][0]
|
||||
assert 'pegin_txout_proof' not in decoded_psbt['inputs'][0]
|
||||
assert 'pegin_genesis_hash' not in decoded_psbt['inputs'][0]
|
||||
merged_pegin_psbt = sidechain.combinepsbt([pegin_psbt, merge_pegin_psbt])
|
||||
assert_equal(pegin_psbt, merged_pegin_psbt)
|
||||
|
||||
sample_pegin_struct = FromHex(CTransaction(), signed_pegin["hex"])
|
||||
# Round-trip peg-in transaction using python serialization
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue