Skip to content

Commit

Permalink
Bugfix: fill_psbt (#1050)
Browse files Browse the repository at this point in the history
* fix fill_psbt

* Fix background of disabled button after reopening partially signed tx

Co-authored-by: benk10 <ben.kaufman10@gmail.com>
  • Loading branch information
stepansnigirev and ben-kaufman committed Mar 23, 2021
1 parent 6c631e4 commit 04c05b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
<div id="signing_container" class="signing_container flex-column {% if psbt['raw'] %}hidden{% endif %}" style="text-align: center;">
<p style="margin-bottom: 15px; margin-top: 0px;">Sign transaction with your:</p>
{% for device in wallet.devices %}
<button type="button" class="btn signing-column-btn" id="{{ device.alias }}_tx_sign_btn" {{ 'disabled style="background-color:#303c49;"' if device.alias in psbt["devices_signed"] else '' }}>
<button type="button" class="btn signing-column-btn" id="{{ device.alias }}_tx_sign_btn" {{ 'disabled style=background-color:#303c49;' if device.alias in psbt["devices_signed"] else '' }}>
{{ device.name }} {% if device.alias in psbt['devices_signed'] %} (&#10004;) {% endif %}
</button>
{% endfor %}
Expand Down
15 changes: 8 additions & 7 deletions src/cryptoadvance/specter/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from .key import Key
from .util.merkleblock import is_valid_merkle_proof
from .helpers import der_to_bytes
from embit import base58
from embit import base58, bip32
from .util.descriptor import Descriptor, sort_descriptor, AddChecksum
from .util.xpub import get_xpub_fingerprint
from .util.tx import decoderawtransaction
from .persistence import write_json_file, delete_file
from hwilib.tx import CTransaction
from hwilib.psbt import PSBT
from hwilib.psbt import PSBT, KeyOriginInfo
from io import BytesIO
from .specter_error import SpecterError
import threading
Expand Down Expand Up @@ -1512,17 +1512,18 @@ def fill_psbt(self, b64psbt, non_witness: bool = True, xpubs: bool = True):
# for multisig add xpub fields
if len(self.keys) > 1:
for k in self.keys:
key = b"\x01" + base58.decode_check(k.xpub)
key = base58.decode_check(k.xpub)
if k.fingerprint != "":
fingerprint = bytes.fromhex(k.fingerprint)
else:
fingerprint = get_xpub_fingerprint(k.xpub)
if k.derivation != "":
der = der_to_bytes(k.derivation)
der = bip32.parse_path(k.derivation)
else:
der = b""
value = fingerprint + der
psbt.unknown[key] = value
der = []
psbt.xpub[key] = KeyOriginInfo(fingerprint, der)
else:
psbt.xpub = {}
return psbt.serialize()

def get_signed_devices(self, decodedpsbt):
Expand Down

0 comments on commit 04c05b6

Please sign in to comment.