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

After latest Trezor firmware update, not possible to sign TX. #34

Closed
ep0x opened this issue Jul 4, 2020 · 9 comments · Fixed by #35
Closed

After latest Trezor firmware update, not possible to sign TX. #34

ep0x opened this issue Jul 4, 2020 · 9 comments · Fixed by #35

Comments

@ep0x
Copy link

ep0x commented Jul 4, 2020


Edited by Christian

@ep0x is correct. The latest version of the firmware is incompatible with the current version of Trezor.Net

I've tried a few times to get it working. You can see my very poor attempt here:

//This code is converted from Trezor.py here:

Which comes from a python example here:
https://github.com/trezor/python-trezor/blob/2813522b05cef4e0e545a101f8b3559a3183b45b/trezorlib/btc.py#L161

If you want to have a go at this, I recommend joining the Trezor dev community on gitter.

This is some documentation about signing transactions:
https://wiki.trezor.io/Developers_guide:Message_Workflows#SignTx


We have problem to sign tx for both models.
Far as i inspected issue, i found :
While sending TxRequest to Trezor One, new requirement is needed such as TxRequest.RequestType.Txmeta ( TXMETA).

Also while doing debugging in our service we noticed when we send TxRequest to device, before device ask us for TXMETA data, now in request.Details.TxHash is not empty like before. There is new things happening now that we need to change.

Now we need to verify prevHas or something. I did a bit inspection in https://github.com/trezor/trezor-firmware/blob/82c0c403677a14bde56c1a6b440a46593a57267d/python/src/trezorlib/btc.py and i found out there is changes in code for txmeta and tx.bin.output added python: Add get_ownership_id() and get_ownership_proof() to trezorlib.

In TrezorLib, inputs value(amount) is not mandatory now if i understand python correctly...

def from_json(json_dict):
    def make_input(vin):
        i = messages.TxInputType()
        if "coinbase" in vin:
            i.prev_hash = b"\0" * 32
            i.prev_index = 0xFFFFFFFF  # signed int -1
            i.script_sig = bytes.fromhex(vin["coinbase"])
            i.sequence = vin["sequence"]

        else:
            i.prev_hash = bytes.fromhex(vin["txid"])
            i.prev_index = vin["vout"]
            i.script_sig = bytes.fromhex(vin["scriptSig"]["hex"])
            i.sequence = vin["sequence"]

        return i

    def make_bin_output(vout):
        o = messages.TxOutputBinType()
        o.amount = int(Decimal(vout["value"]) * (10 ** 8))
        o.script_pubkey = bytes.fromhex(vout["scriptPubKey"]["hex"])
        return o

    t = messages.TransactionType()
    t.version = json_dict["version"]
    t.lock_time = json_dict.get("locktime")
    t.inputs = [make_input(vin) for vin in json_dict["vin"]]
    t.bin_outputs = [make_bin_output(vout) for vout in json_dict["vout"]]
    return t

About TX_META

  
def copy_tx_meta(tx):
        tx_copy = messages.TransactionType(**tx)
        # clear fields
        tx_copy.inputs_cnt = len(tx.inputs)
        tx_copy.inputs = []
        tx_copy.outputs_cnt = len(tx.bin_outputs or tx.outputs)
        tx_copy.outputs = []
        tx_copy.bin_outputs = []
        tx_copy.extra_data_len = len(tx.extra_data or b"")
        tx_copy.extra_data = None
        return tx_copy


if res.request_type == R.TXMETA:
            msg = copy_tx_meta(current_tx)
            res = client.call(messages.TxAck(tx=msg))

And here is trick with request for TXOUTPUT. Now he is checking if there is request.Details.TxHash and if is has is presented then bin_outputs must be set...

elif res.request_type == R.TXOUTPUT:
            msg = messages.TransactionType()
            if res.details.tx_hash:
                msg.bin_outputs = [current_tx.bin_outputs[res.details.request_index]]
            else:
                msg.outputs = [current_tx.outputs[res.details.request_index]]

            res = client.call(messages.TxAck(tx=msg))


In Trezor Model T there is error in firmware message when you try to sign TX.

I am willing to help but idk from where to start...
I noticed there is a lot problems with new firmware for many wallets and services like Wasabi and BtcPayServer, but idk did he fixed issue, he used HWI for his Wasabi project.
I am willing to help if i can in anyway.
It would be awesome if we can join all together and maintain one Lib for Trezor instead 5 different libs at once and having the same issue...

I'd be glad if we could join this project, our respected colleagues like @NicolasDorier and @lontivero @bitcoinbrisbane
Any help are welcome!

Thank you in advance.

@MelbourneDeveloper
Copy link
Owner

@ep0x you probably upgraded the trezor firmware right?

Trezor.net needs to upgrade. You can help by regenerating the protobuf code. You can get that from Satoshi labs.

Otherwise I will do it eventually

@ep0x
Copy link
Author

ep0x commented Jul 4, 2020

@MelbourneDeveloper Correct, all our devices has been updated and we encounter problems with signing TX.
protobuf will fix problems with signing TX?
For regenerating protobuf code, did you used protobuf compiler to regenerate? I am not exactly sure how to do it.

@MelbourneDeveloper
Copy link
Owner

@ep0x yes. Time to learn!

Here is an old article about it. It's out of date but it's a starting point.

https://christianfindlay.com/2018/01/31/developing-software-for-satoshi-labs-trezor-hardware-wallet-part-1/

Otherwise you can wait for me.

@MelbourneDeveloper
Copy link
Owner

@ep0x the other option is that you can pay me to fix it.

@ep0x
Copy link
Author

ep0x commented Jul 4, 2020

@MelbourneDeveloper I didn't ask for payment from your side in this case MelbourneDeveloper/KeepKey.Net#6
I did donate more than 400$...
but np i can donate again :) fix Tx Signing and donation is coming is that ok for you?

@MelbourneDeveloper
Copy link
Owner

@ep0x you donated?

Sorry, can you point me to the transaction please? If you sent $400 that's a big donation.

@MelbourneDeveloper
Copy link
Owner

@ep0x please DM me through my website or Twitter and we can negotiate

@ep0x
Copy link
Author

ep0x commented Jul 4, 2020

@MelbourneDeveloper I sent an email to you from prev conversation :) u have tx in email ;) but sure for your work i will donate again.

@ep0x
Copy link
Author

ep0x commented Jul 4, 2020

@MelbourneDeveloper my mistake, around 60$ was donation. Sorry whole transaction was around 500$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants