mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-24 18:23:26 -03:00
signet/miner: drop get_reward_address function
This commit is contained in:
parent
6ff0aa089c
commit
3aed0a4284
1 changed files with 14 additions and 23 deletions
|
@ -139,35 +139,26 @@ def generate_psbt(tmpl, reward_spk, *, blocktime=None):
|
|||
|
||||
return do_createpsbt(block, signme, spendme)
|
||||
|
||||
def get_reward_address(args, height):
|
||||
if args.address is not None:
|
||||
return args.address
|
||||
|
||||
if '*' not in args.descriptor:
|
||||
addr = json.loads(args.bcli("deriveaddresses", args.descriptor))[0]
|
||||
args.address = addr
|
||||
return addr
|
||||
|
||||
remove = [k for k in args.derived_addresses.keys() if k+20 <= height]
|
||||
for k in remove:
|
||||
del args.derived_addresses[k]
|
||||
|
||||
addr = args.derived_addresses.get(height, None)
|
||||
if addr is None:
|
||||
addrs = json.loads(args.bcli("deriveaddresses", args.descriptor, "[%d,%d]" % (height, height+20)))
|
||||
addr = addrs[0]
|
||||
for k, a in enumerate(addrs):
|
||||
args.derived_addresses[height+k] = a
|
||||
|
||||
return addr
|
||||
|
||||
def get_reward_addr_spk(args, height):
|
||||
assert args.address is not None or args.descriptor is not None
|
||||
|
||||
if hasattr(args, "reward_spk"):
|
||||
return args.address, args.reward_spk
|
||||
|
||||
reward_addr = get_reward_address(args, height)
|
||||
if args.address is not None:
|
||||
reward_addr = args.address
|
||||
elif '*' not in args.descriptor:
|
||||
reward_addr = args.address = json.loads(args.bcli("deriveaddresses", args.descriptor))[0]
|
||||
else:
|
||||
remove = [k for k in args.derived_addresses.keys() if k+20 <= height]
|
||||
for k in remove:
|
||||
del args.derived_addresses[k]
|
||||
if height not in args.derived_addresses:
|
||||
addrs = json.loads(args.bcli("deriveaddresses", args.descriptor, "[%d,%d]" % (height, height+20)))
|
||||
for k, a in enumerate(addrs):
|
||||
args.derived_addresses[height+k] = a
|
||||
reward_addr = args.derived_addresses[height]
|
||||
|
||||
reward_spk = bytes.fromhex(json.loads(args.bcli("getaddressinfo", reward_addr))["scriptPubKey"])
|
||||
if args.address is not None:
|
||||
# will always be the same, so cache
|
||||
|
|
Loading…
Add table
Reference in a new issue