1
0

transaction: put full derivation paths into PSBT by default

There are three export options for exporting a PSBT.
The default option previously only put derivation path suffixes for pubkeys
(paths relative to the intermediate xpub), now it puts the full path
(if is known by the keystore).

The "export for hardware device; include xpubs" option works same as before:
it puts both full paths and also global xpubs into the PSBT.
Hence the difference between the default option and the "include xpubs" option
is now only that the latter puts global xpubs into the PSBT.

This change is largely made for user-convenient in mind.
Now exporting a PSBT should be less error-prone: particularly for the
single-signer coldcard with sdcard usage, the default option will now work.

closes #5969
related #5955
This commit is contained in:
SomberNight
2020-12-10 17:36:02 +01:00
parent c3c64a37c2
commit c81551299e
5 changed files with 57 additions and 46 deletions

View File

@@ -349,8 +349,12 @@ class MasterPublicKeyMixin(ABC):
pass
@abstractmethod
def get_fp_and_derivation_to_be_used_in_partial_tx(self, der_suffix: Sequence[int], *,
only_der_suffix: bool = True) -> Tuple[bytes, Sequence[int]]:
def get_fp_and_derivation_to_be_used_in_partial_tx(
self,
der_suffix: Sequence[int],
*,
only_der_suffix: bool,
) -> Tuple[bytes, Sequence[int]]:
"""Returns fingerprint and derivation path corresponding to a derivation suffix.
The fingerprint is either the root fp or the intermediate fp, depending on what is available
and 'only_der_suffix', and the derivation path is adjusted accordingly.
@@ -449,8 +453,12 @@ class Xpub(MasterPublicKeyMixin):
def get_root_fingerprint(self) -> Optional[str]:
return self._root_fingerprint
def get_fp_and_derivation_to_be_used_in_partial_tx(self, der_suffix: Sequence[int], *,
only_der_suffix: bool = True) -> Tuple[bytes, Sequence[int]]:
def get_fp_and_derivation_to_be_used_in_partial_tx(
self,
der_suffix: Sequence[int],
*,
only_der_suffix: bool,
) -> Tuple[bytes, Sequence[int]]:
fingerprint_hex = self.get_root_fingerprint()
der_prefix_str = self.get_derivation_prefix()
if not only_der_suffix and fingerprint_hex is not None and der_prefix_str is not None:
@@ -721,8 +729,12 @@ class Old_KeyStore(MasterPublicKeyMixin, Deterministic_KeyStore):
self._root_fingerprint = xfp.hex().lower()
return self._root_fingerprint
def get_fp_and_derivation_to_be_used_in_partial_tx(self, der_suffix: Sequence[int], *,
only_der_suffix: bool = True) -> Tuple[bytes, Sequence[int]]:
def get_fp_and_derivation_to_be_used_in_partial_tx(
self,
der_suffix: Sequence[int],
*,
only_der_suffix: bool,
) -> Tuple[bytes, Sequence[int]]:
fingerprint_hex = self.get_root_fingerprint()
der_prefix_str = self.get_derivation_prefix()
fingerprint_bytes = bfh(fingerprint_hex)