lightning: use derivePrivKey in signOutputRaw
This commit is contained in:
parent
b017301f84
commit
40005dc00d
@ -469,11 +469,7 @@ def SignOutputRaw(json):
|
|||||||
|
|
||||||
|
|
||||||
def signOutputRaw(tx, signDesc):
|
def signOutputRaw(tx, signDesc):
|
||||||
adr = None
|
pri = derivePrivKey(signDesc)
|
||||||
if len(signDesc.keyDescriptor.pubKey) != 0:
|
|
||||||
adr = bitcoin.pubkey_to_address('p2wpkh', binascii.hexlify(
|
|
||||||
signDesc.keyDescriptor.pubKey).decode("utf-8")) # Because this is all NewAddress supports
|
|
||||||
pri = fetchPrivKey(adr, signDesc.keyDescriptor.keyLocator.family, signDesc.keyDescriptor.keyLocator.index)
|
|
||||||
pri2 = maybeTweakPrivKey(signDesc, pri)
|
pri2 = maybeTweakPrivKey(signDesc, pri)
|
||||||
sig = rawTxInWitnessSignature(tx, signDesc.sigHashes, signDesc.inputIndex,
|
sig = rawTxInWitnessSignature(tx, signDesc.sigHashes, signDesc.inputIndex,
|
||||||
signDesc.output.value, signDesc.witnessScript, sigHashAll, pri2)
|
signDesc.output.value, signDesc.witnessScript, sigHashAll, pri2)
|
||||||
@ -801,6 +797,7 @@ async def readReqAndReply(obj, writer):
|
|||||||
await writer.drain()
|
await writer.drain()
|
||||||
|
|
||||||
def privKeyForPubKey(pubKey):
|
def privKeyForPubKey(pubKey):
|
||||||
|
global globalIdx
|
||||||
priv_keys = WALLET.storage.get("lightning_extra_keys", [])
|
priv_keys = WALLET.storage.get("lightning_extra_keys", [])
|
||||||
for i in priv_keys:
|
for i in priv_keys:
|
||||||
candidate = EC_KEY(i.to_bytes(32, "big"))
|
candidate = EC_KEY(i.to_bytes(32, "big"))
|
||||||
@ -827,7 +824,6 @@ def privKeyForPubKey(pubKey):
|
|||||||
#assert False, "could not find private key for pubkey {} hex={}".format(pubKey, binascii.hexlify(pubKey).decode("ascii"))
|
#assert False, "could not find private key for pubkey {} hex={}".format(pubKey, binascii.hexlify(pubKey).decode("ascii"))
|
||||||
|
|
||||||
def derivePrivKey(keyDesc):
|
def derivePrivKey(keyDesc):
|
||||||
global globalIdx
|
|
||||||
keyDescFam = keyDesc.keyLocator.family
|
keyDescFam = keyDesc.keyLocator.family
|
||||||
keyDescIdx = keyDesc.keyLocator.index
|
keyDescIdx = keyDesc.keyLocator.index
|
||||||
keyDescPubKey = keyDesc.pubKey
|
keyDescPubKey = keyDesc.pubKey
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user