Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use .psbt extension for PSBT files #5954

Open
Sjors opened this issue Feb 13, 2020 · 8 comments
Open

Use .psbt extension for PSBT files #5954

Sjors opened this issue Feb 13, 2020 · 8 comments
Assignees
Milestone

Comments

@Sjors
Copy link

@Sjors Sjors commented Feb 13, 2020

On the latest master branch, PSBT (binary) files are saved with a .txn extension. Bitcoin Core is probably going to use the .psbt extension, see bitcoin/bitcoin#17509. An iOs app that I'm working on is able to open .psbt files too, including launching the app by opening / airdropping the file. ColdCard is able to read .psbt files too.

BIP174 didn't add a magic byte to the serialized format, so the file extension matters.

@SomberNight

This comment has been minimized.

Copy link
Member

@SomberNight SomberNight commented Feb 13, 2020

On the latest master branch, PSBT (binary) files are saved with a .txn extension

Are you sure of this?
AFAICT, complete transactions are saved with .txn, and partial ones are saved with .psbt.

BIP174 didn't add a magic byte to the serialized format, so the file extension matters.

I don't quite understand this point -- I expect these files would contain just a PSBT in binary, i.e. the first five bytes are known 70736274ff (in hex)?

@Sjors

This comment has been minimized.

Copy link
Author

@Sjors Sjors commented Feb 13, 2020

I tried it with a 2-of-3 multisig (all external keys) today. Perhaps it misinterpreted it as complete?

I overlooked 0x70736274 in the spec, those are indeed "Magic bytes which are ASCII for psbt".

@SomberNight

This comment has been minimized.

Copy link
Member

@SomberNight SomberNight commented Feb 13, 2020

I tried it with a 2-of-3 multisig (all external keys) today. Perhaps it misinterpreted it as complete?

Well... not sure - I guess?
I've tried now with a 2of3 wallet comprised of 3 Upubs, created an unsigned tx and exported it directly. It resulted in a .psbt

The relevant code is here:

def export_to_file(self, *, tx: Transaction = None):
if tx is None:
tx = self.tx
if isinstance(tx, PartialTransaction):
tx.finalize_psbt()
if tx.is_complete():
name = 'signed_%s.txn' % (tx.txid()[0:8])
else:
name = self.wallet.basename() + time.strftime('-%Y%m%d-%H%M.psbt')
fileName = self.main_window.getSaveFileName(_("Select where to save your transaction"),
name,
TRANSACTION_FILE_EXTENSION_FILTER)

@Sjors

This comment has been minimized.

Copy link
Author

@Sjors Sjors commented Feb 13, 2020

Well... not sure - I guess?

I distinctly remember renaming the file extension. Just tried again (macOS, built and installed DMG from 5d8d8f7): click on Pay, then click on Send, then click on Export, then click on Export to File.

Schermafbeelding 2020-02-13 om 21 27 59

The result is .txn file.

If I click Save instead of Export it crashes:

E | gui.qt.exception_window.Exception_Hook | exception caught by crash reporter
Traceback (most recent call last):
  File "electrum/gui/qt/transaction_dialog.py", line 297, in save
  File "electrum/gui/qt/main_window.py", line 3009, in save_transaction_into_wallet
  File "electrum/util.py", line 425, in <lambda>
  File "electrum/util.py", line 421, in do_profile
TypeError: write() missing 1 required positional argument: 'data'
E | gui.qt.exception_window.Exception_Hook | exception caught by crash reporter
Traceback (most recent call last):
  File "electrum/gui/qt/transaction_dialog.py", line 297, in save
  File "electrum/gui/qt/main_window.py", line 3009, in save_transaction_into_wallet
  File "electrum/util.py", line 425, in <lambda>
  File "electrum/util.py", line 421, in do_profile
TypeError: write() missing 1 required positional argument: 'data'

Mine uses Vpubs (native segwit multisig) in case that could matter.

@SomberNight

This comment has been minimized.

Copy link
Member

@SomberNight SomberNight commented Feb 13, 2020

If I click Save instead of Export it crashes:

ignore that; unrelated. should be ok with 111ef9e

[image]

So this is on MacOS? What is your version of Qt?
from PyQt5.QtCore import QT_VERSION_STR; from PyQt5.QtCore import PYQT_VERSION_STR; print(f"Qt: {QT_VERSION_STR}. PyQt: {PYQT_VERSION_STR}")

I fear this will end up being a platform quirk.

@SomberNight

This comment has been minimized.

Copy link
Member

@SomberNight SomberNight commented Feb 13, 2020

Ah ok, I see you've actually said you built a binary.
Then the versions are pinned down.

@Sjors

This comment has been minimized.

Copy link
Author

@Sjors Sjors commented Feb 13, 2020

QT 5.14.1 via Homebrew. With your incantation: Qt: 5.11.2. PyQt: 5.11.3 (not sure why those versions don't match)

@SomberNight

This comment has been minimized.

Copy link
Member

@SomberNight SomberNight commented Feb 13, 2020

Ok I confirm that all txns are saved with the .txn extension.
I have tested on Win10, Ubuntu 18.04, and MacOS 10.11 now.
It is only happening on MacOS.

As in your picture, on MacOS, the extension we set is being stripped from the name for some reason, and then I guess it is just picking the first extension listed in the filter, which is .txn.


EDIT: Also happens on MacOS 10.14, both with pyqt5==5.11.3 and pyqt5==5.14.1.

@SomberNight SomberNight added this to the 4.0 milestone Feb 14, 2020
@SomberNight SomberNight self-assigned this Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.