mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 08:51:32 +00:00
lnbase: fix funding address, funding_output_index
This commit is contained in:
parent
5a4ab74c77
commit
451d52281a
1 changed files with 11 additions and 10 deletions
|
@ -26,7 +26,7 @@ from . import bitcoin
|
||||||
from .constants import set_testnet, set_simnet
|
from .constants import set_testnet, set_simnet
|
||||||
from . import constants
|
from . import constants
|
||||||
from . import transaction
|
from . import transaction
|
||||||
from .util import PrintError
|
from .util import PrintError, bh2u
|
||||||
from .wallet import Wallet
|
from .wallet import Wallet
|
||||||
from .storage import WalletStorage
|
from .storage import WalletStorage
|
||||||
|
|
||||||
|
@ -396,22 +396,23 @@ class Peer(PrintError):
|
||||||
finally:
|
finally:
|
||||||
del self.temporary_channel_id_to_incoming_accept_channel[temp_channel_id]
|
del self.temporary_channel_id_to_incoming_accept_channel[temp_channel_id]
|
||||||
remote_pubkey = accept_channel["funding_pubkey"]
|
remote_pubkey = accept_channel["funding_pubkey"]
|
||||||
if int.from_bytes(remote_pubkey, byteorder="big") < int.from_bytes(funding_pubkey, byteorder="big"):
|
pubkeys = sorted([bh2u(funding_pubkey), bh2u(remote_pubkey)])
|
||||||
pubkeys = [remote_pubkey, funding_pubkey]
|
redeem_script = transaction.multisig_script(pubkeys, 2)
|
||||||
else:
|
funding_address = bitcoin.redeem_script_to_address('p2wsh', redeem_script)
|
||||||
pubkeys = [funding_pubkey, remote_pubkey]
|
|
||||||
scr = transaction.multisig_script([binascii.hexlify(x).decode("ascii") for x in pubkeys], 2)
|
|
||||||
#TODO support passwd, fix fee
|
#TODO support passwd, fix fee
|
||||||
tx = wallet.mktx([(bitcoin.TYPE_SCRIPT, scr, 20000)], None, config, 1000)
|
funding_output = (bitcoin.TYPE_ADDRESS, funding_address, 20000)
|
||||||
|
tx = wallet.mktx([funding_output], None, config, 1000)
|
||||||
|
funding_index = tx.outputs().index(funding_output)
|
||||||
tx.sign({funding_pubkey: (funding_privkey, True)})
|
tx.sign({funding_pubkey: (funding_privkey, True)})
|
||||||
|
# this is wrong: you need to send the signature of the first commitment tx
|
||||||
sig = bytes.fromhex(tx.inputs()[0]["signatures"][0])
|
sig = bytes.fromhex(tx.inputs()[0]["signatures"][0])
|
||||||
|
self.print_error('sig', len(sig))
|
||||||
sig = bytes(sig[:len(sig)-1])
|
sig = bytes(sig[:len(sig)-1])
|
||||||
r, s = sigdecode_der(sig, SECP256k1.generator.order())
|
r, s = sigdecode_der(sig, SECP256k1.generator.order())
|
||||||
sig = sigencode_string_canonize(r, s, SECP256k1.generator.order())
|
sig = sigencode_string_canonize(r, s, SECP256k1.generator.order())
|
||||||
print(sig)
|
self.print_error('canonical signature', len(sig))
|
||||||
|
|
||||||
self.temporary_channel_id_to_incoming_funding_signed[temp_channel_id] = asyncio.Future()
|
self.temporary_channel_id_to_incoming_funding_signed[temp_channel_id] = asyncio.Future()
|
||||||
self.send_message(gen_msg("funding_created", temporary_channel_id=temp_channel_id, funding_txid=bytes.fromhex(tx.txid()), funding_output_index=0, signature=sig))
|
self.send_message(gen_msg("funding_created", temporary_channel_id=temp_channel_id, funding_txid=bytes.fromhex(tx.txid()), funding_output_index=funding_index, signature=sig))
|
||||||
try:
|
try:
|
||||||
funding_signed = await self.temporary_channel_id_to_incoming_funding_signed[temp_channel_id]
|
funding_signed = await self.temporary_channel_id_to_incoming_funding_signed[temp_channel_id]
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Add table
Reference in a new issue