integrate PSBT support natively. WIP
This commit is contained in:
@@ -9,7 +9,7 @@ from electrum.lnutil import (RevocationStore, get_per_commitment_secret_from_see
|
||||
get_compressed_pubkey_from_bech32, split_host_port, ConnStringFormatError,
|
||||
ScriptHtlc, extract_nodeid, calc_onchain_fees, UpdateAddHtlc)
|
||||
from electrum.util import bh2u, bfh
|
||||
from electrum.transaction import Transaction
|
||||
from electrum.transaction import Transaction, PartialTransaction
|
||||
|
||||
from . import ElectrumTestCase
|
||||
|
||||
@@ -570,7 +570,7 @@ class TestLNUtil(ElectrumTestCase):
|
||||
localhtlcsig=bfh(local_sig),
|
||||
payment_preimage=htlc_payment_preimage if success else b'', # will put 00 on witness if timeout
|
||||
witness_script=htlc)
|
||||
our_htlc_tx._inputs[0]['witness'] = bh2u(our_htlc_tx_witness)
|
||||
our_htlc_tx._inputs[0].witness = our_htlc_tx_witness
|
||||
return str(our_htlc_tx)
|
||||
|
||||
def test_commitment_tx_with_one_output(self):
|
||||
@@ -669,7 +669,7 @@ class TestLNUtil(ElectrumTestCase):
|
||||
ref_commit_tx_str = '02000000000101bef67e4e2fb9ddeeb3461973cd4c62abb35050b1add772995b820b584a488489000000000038b02b8002c0c62d0000000000160014ccf1af2f2aabee14bb40fa3851ab2301de84311054a56a00000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e0400473044022051b75c73198c6deee1a875871c3961832909acd297c6b908d59e3319e5185a46022055c419379c5051a78d00dbbce11b5b664a0c22815fbcc6fcef6b1937c383693901483045022100f51d2e566a70ba740fc5d8c0f07b9b93d2ed741c3c0860c613173de7d39e7968022041376d520e9c0e1ad52248ddf4b22e12be8763007df977253ef45a4ca3bdb7c001475221023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb21030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c152ae3e195220'
|
||||
self.assertEqual(str(our_commit_tx), ref_commit_tx_str)
|
||||
|
||||
def sign_and_insert_remote_sig(self, tx, remote_pubkey, remote_signature, pubkey, privkey):
|
||||
def sign_and_insert_remote_sig(self, tx: PartialTransaction, remote_pubkey, remote_signature, pubkey, privkey):
|
||||
assert type(remote_pubkey) is bytes
|
||||
assert len(remote_pubkey) == 33
|
||||
assert type(remote_signature) is str
|
||||
@@ -678,10 +678,7 @@ class TestLNUtil(ElectrumTestCase):
|
||||
assert len(pubkey) == 33
|
||||
assert len(privkey) == 33
|
||||
tx.sign({bh2u(pubkey): (privkey[:-1], True)})
|
||||
pubkeys, _x_pubkeys = tx.get_sorted_pubkeys(tx.inputs()[0])
|
||||
index_of_pubkey = pubkeys.index(bh2u(remote_pubkey))
|
||||
tx._inputs[0]["signatures"][index_of_pubkey] = remote_signature + "01"
|
||||
tx.raw = None
|
||||
tx.add_signature_to_txin(txin_idx=0, signing_pubkey=remote_pubkey.hex(), sig=remote_signature + "01")
|
||||
|
||||
def test_get_compressed_pubkey_from_bech32(self):
|
||||
self.assertEqual(b'\x03\x84\xef\x87\xd9d\xa2\xaaa7=\xff\xb8\xfe=t8[}>;\n\x13\xa8e\x8eo:\xf5Mi\xb5H',
|
||||
|
||||
Reference in New Issue
Block a user