Skip to content

Commit

Permalink
post rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ecdsa committed Mar 6, 2019
1 parent 0d921cd commit 84c0606
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
6 changes: 3 additions & 3 deletions electrum/lnutil.py
Expand Up @@ -237,7 +237,7 @@ def make_htlc_tx_output(amount_msat, local_feerate, revocationpubkey, local_dela
+ bfh(push_script(bh2u(revocationpubkey))) \
+ bytes([opcodes.OP_ELSE]) \
+ bitcoin.add_number_to_script(to_self_delay) \
+ bytes([opcodes.OP_CSV, opcodes.OP_DROP]) \
+ bytes([opcodes.OP_CHECKSEQUENCEVERIFY, opcodes.OP_DROP]) \
+ bfh(push_script(bh2u(local_delayedpubkey))) \
+ bytes([opcodes.OP_ENDIF, opcodes.OP_CHECKSIG])

Expand Down Expand Up @@ -319,7 +319,7 @@ def make_received_htlc(revocation_pubkey: bytes, remote_htlcpubkey: bytes,
+ bitcoin.add_number_to_script(2) \
+ bytes([opcodes.OP_CHECKMULTISIG, opcodes.OP_ELSE, opcodes.OP_DROP]) \
+ bitcoin.add_number_to_script(cltv_expiry) \
+ bytes([opcodes.OP_CLTV, opcodes.OP_DROP, opcodes.OP_CHECKSIG, opcodes.OP_ENDIF, opcodes.OP_ENDIF])
+ bytes([opcodes.OP_CHECKLOCKTIMEVERIFY, opcodes.OP_DROP, opcodes.OP_CHECKSIG, opcodes.OP_ENDIF, opcodes.OP_ENDIF])

def make_htlc_output_witness_script(is_received_htlc: bool, remote_revocation_pubkey: bytes, remote_htlc_pubkey: bytes,
local_htlc_pubkey: bytes, payment_hash: bytes, cltv_expiry: Optional[int]) -> bytes:
Expand Down Expand Up @@ -473,7 +473,7 @@ def make_commitment(ctn, local_funding_pubkey, remote_funding_pubkey,
def make_commitment_output_to_local_witness_script(
revocation_pubkey: bytes, to_self_delay: int, delayed_pubkey: bytes) -> bytes:
local_script = bytes([opcodes.OP_IF]) + bfh(push_script(bh2u(revocation_pubkey))) + bytes([opcodes.OP_ELSE]) + bitcoin.add_number_to_script(to_self_delay) \
+ bytes([opcodes.OP_CSV, opcodes.OP_DROP]) + bfh(push_script(bh2u(delayed_pubkey))) + bytes([opcodes.OP_ENDIF, opcodes.OP_CHECKSIG])
+ bytes([opcodes.OP_CHECKSEQUENCEVERIFY, opcodes.OP_DROP]) + bfh(push_script(bh2u(delayed_pubkey))) + bytes([opcodes.OP_ENDIF, opcodes.OP_CHECKSIG])
return local_script

def make_commitment_output_to_local_address(
Expand Down
4 changes: 2 additions & 2 deletions electrum/lnwatcher.py
Expand Up @@ -211,7 +211,7 @@ def inspect_tx_candidate(self, outpoint, n):
# FIXME: instead of stopping recursion at n == 2,
# we should detect which outputs are HTLCs
prev_txid, index = outpoint.split(':')
txid = self.spent_outpoints[prev_txid].get(int(index))
txid = self.db.get_spent_outpoint(prev_txid, int(index))
result = {outpoint:txid}
if txid is None:
self.channel_status[outpoint] = 'open'
Expand All @@ -224,7 +224,7 @@ def inspect_tx_candidate(self, outpoint, n):
else:
self.channel_status[outpoint] = 'closed (deep)'

tx = self.transactions[txid]
tx = self.db.get_transaction(txid)
for i, o in enumerate(tx.outputs()):
if o.address not in self.get_addresses():
self.add_address(o.address)
Expand Down
5 changes: 3 additions & 2 deletions electrum/lnworker.py
Expand Up @@ -25,7 +25,7 @@
from .bitcoin import COIN
from .transaction import Transaction
from .crypto import sha256
from .bip32 import bip32_root
from .bip32 import BIP32Node
from .util import bh2u, bfh, PrintError, InvoiceError, resolve_dns_srv, is_ip_address, log_exceptions
from .util import timestamp_to_datetime
from .lntransport import LNTransport, LNResponderTransport
Expand Down Expand Up @@ -217,7 +217,8 @@ def _read_ln_keystore(self) -> BIP32_KeyStore:
# TODO derive this deterministically from wallet.keystore at keystore generation time
# probably along a hardened path ( lnd-equivalent would be m/1017'/coinType'/ )
seed = os.urandom(32)
xprv, xpub = bip32_root(seed, xtype='standard')
node = BIP32Node.from_rootseed(seed, xtype='standard')
xprv = node.to_xprv()
self.storage.put('lightning_privkey2', xprv)
return keystore.from_xprv(xprv)

Expand Down
5 changes: 2 additions & 3 deletions electrum/tests/test_lnchannel.py
Expand Up @@ -99,9 +99,8 @@ def create_channel_state(funding_txid, funding_index, funding_sat, local_feerate
}

def bip32(sequence):
xprv, xpub = bip32_utils.bip32_root(b"9dk", 'standard')
xprv, xpub = bip32_utils.bip32_private_derivation(xprv, "m/", sequence)
xtype, depth, fingerprint, child_number, c, k = bip32_utils.deserialize_xprv(xprv)
node = bip32_utils.BIP32Node.from_rootseed(b"9dk", xtype='standard').subkey_at_private_derivation(sequence)
k = node.eckey.get_secret_bytes()
assert len(k) == 32
assert type(k) is bytes
return k
Expand Down
2 changes: 0 additions & 2 deletions electrum/verifier.py
Expand Up @@ -135,8 +135,6 @@ async def _request_and_verify_single_proof(self, tx_hash, tx_height):
txpos=pos,
header_hash=header_hash)
self.wallet.add_verified_tx(tx_hash, tx_info)
if self.is_up_to_date() and self.wallet.is_up_to_date():
self.wallet.save_verified_tx(write=True)

@classmethod
def hash_merkle_root(cls, merkle_branch: Sequence[str], tx_hash: str, leaf_pos_in_tree: int):
Expand Down

0 comments on commit 84c0606

Please sign in to comment.