follow-up descriptor.py: small clean-up
This commit is contained in:
@@ -442,7 +442,7 @@ def redeem_script_to_address(txin_type: str, scriptcode: str, *, net=None) -> st
|
||||
raise NotImplementedError(txin_type)
|
||||
|
||||
|
||||
def script_to_address(script: str, *, net=None) -> str:
|
||||
def script_to_address(script: str, *, net=None) -> Optional[str]:
|
||||
from .transaction import get_address_from_output_script
|
||||
return get_address_from_output_script(bfh(script), net=net)
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class ExpandedScripts:
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
output_script: Optional[bytes] = None,
|
||||
output_script: bytes, # "scriptPubKey"
|
||||
redeem_script: Optional[bytes] = None,
|
||||
witness_script: Optional[bytes] = None,
|
||||
scriptcode_for_sighash: Optional[bytes] = None
|
||||
@@ -75,8 +75,7 @@ class ExpandedScripts:
|
||||
self._scriptcode_for_sighash = value
|
||||
|
||||
def address(self, *, net=None) -> Optional[str]:
|
||||
if spk := self.output_script:
|
||||
return bitcoin.script_to_address(spk.hex(), net=net)
|
||||
return bitcoin.script_to_address(self.output_script.hex(), net=net)
|
||||
|
||||
|
||||
class ScriptSolutionInner(NamedTuple):
|
||||
|
||||
@@ -107,8 +107,6 @@ async def _append_utxos_to_inputs(
|
||||
inputs: List[PartialTxInput],
|
||||
network: 'Network',
|
||||
script_descriptor: 'descriptor.Descriptor',
|
||||
pubkey: str,
|
||||
txin_type: str,
|
||||
imax: int,
|
||||
) -> None:
|
||||
script = script_descriptor.expand().output_script.hex()
|
||||
@@ -145,8 +143,6 @@ async def sweep_preparations(privkeys, network: 'Network', imax=100):
|
||||
inputs=inputs,
|
||||
network=network,
|
||||
script_descriptor=desc,
|
||||
pubkey=pubkey,
|
||||
txin_type=txin_type,
|
||||
imax=imax)
|
||||
keypairs[pubkey] = privkey, compressed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user