-
Notifications
You must be signed in to change notification settings - Fork 28
Trezor SignTx Messages
Here is an example of the Trezor signing workflow detailing the messages that pass back and forth between a Trezor and MultiBit Hardware.
This approach allows the Trezor, which has very limited internal capacity, to sign arbitrarily large transactions by breaking the exploration of the proposed transaction into manageable chunks. Essentially the Trezor explores the transactions hanging off the inputs to the proposed transaction verifying their signatures and hashes.
When all the transactions have been explored it will begin the signing process (asking the user to confirm each output) and deliver each input signature in a separate message. This again allows arbitrarily large transactions to be processed in smaller pieces.
Proposed tx has 2 outputs and 1 input
> Message:SignTx
outputsCount_=2
inputsCount_=1
coinName_=Bitcoin
Request input 0 on proposed Tx.
< Message:TxRequest
requestType_=TXINPUT
details_=
request_index: 0
tx_hash:
serialized_=
serialized_size: 0
serialized_tx:
signature_index: 0
signature:
Input 0 on proposed Tx has 1 input of type SPENDADDRESS on Tx:8742badeb461c3502f0a84c9df41b73eda7e88b978aa323aa8871c108df27e0e. This spends to our address 44'/0'/0'/0/0.
> Message:TxAck
tx_=
bin_outputs_count: 0
inputs_cnt: 0
inputs_count: 1
sequence: 0
addressN: 8000002c (44')
addressN: 80000000 (0')
addressN: 80000000 (0')
addressN: 0
addressN: 0
prev_hash: 8742badeb461c3502f0a84c9df41b73eda7e88b978aa323aa8871c108df27e0e
prev_index: 0
script_type: SPENDADDRESS
outputs_cnt: 0
outputs_count: 0
lock_time: 0
version: 0
Request information on Tx:8742badeb461c3502f0a84c9df41b73eda7e88b978aa323aa8871c108df27e0e
< Message:TxRequest
requestType_=TXMETA
details_=
request_index: 0
tx_hash: 8742badeb461c3502f0a84c9df41b73eda7e88b978aa323aa8871c108df27e0e
serialized_=
serialized_size: 0
serialized_tx:
signature_index: 0
signature:
Prev Tx has 1 input and 2 outputs, lock time is 0 and version is 1.
> Message:TxAck
tx_=
bin_outputs_count: 0
inputs_cnt: 1
inputs_count: 0
outputs_cnt: 2
outputs_count: 0
lock_time: 0
version: 1
Request information on prev Tx input 0
< Message:TxRequest
requestType_=TXINPUT
details_=
request_index: 0
tx_hash: 8742badeb461c3502f0a84c9df41b73eda7e88b978aa323aa8871c108df27e0e
serialized_=
serialized_size: 0
serialized_tx:
signature_index: 0
signature:
]
Input 0 on prev Tx links to output 1 on Tx:ec2400fa72eb4ad588e080e3e15f987bbd876a1508aefdf6d8bf1fe21ae6a33e. It is a SPENDADDRESS with a script signature of 483045022100dcaf9241a813699c584b664587d80219ea30ad0b847cec7c6b77aededb743f170220234d646304388ca13a9bebda84413b9e95218b73ceb3bd72a0f5a7d94ff29ef2012102f846445ee80fd95492ee3357257f588815ae8e077f6733e77b83d7d97dac3588
> Message:TxAck
tx_=
bin_outputs_count: 0
inputs_cnt: 0
inputs_count: 1
prev_hash: ec2400fa72eb4ad588e080e3e15f987bbd876a1508aefdf6d8bf1fe21ae6a33e
prev_index: 1
script_type: SPENDADDRESS
script_sig: 483045022100dcaf9241a813699c584b664587d80219ea30ad0b847cec7c6b77aededb743f170220234d646304388ca13a9bebda84413b9e95218b73ceb3bd72a0f5a7d94ff29ef2012102f846445ee80fd95492ee3357257f588815ae8e077f6733e77b83d7d97dac3588
outputs_cnt: 0
outputs_count: 0
lock_time: 0
version: 0
Request output 0 on Tx:8742badeb461c3502f0a84c9df41b73eda7e88b978aa323aa8871c108df27e0e
< Message:TxRequest
requestType_=TXOUTPUT
details_=
request_index: 0
tx_hash: 8742badeb461c3502f0a84c9df41b73eda7e88b978aa323aa8871c108df27e0e
serialized_=
serialized_size: 0
serialized_tx:
signature_index: 0
signature:
Output 0 on Tx:8742badeb461c3502f0a84c9df41b73eda7e88b978aa323aa8871c108df27e0e has amount 1000000. Script program is 76a9149fb230929fcf2d4ed5fabd80cc33b5ef521bb89788ac
> Message:TxAck
tx_=
bin_outputs_count: 1
script_pubkey: 76a9149fb230929fcf2d4ed5fabd80cc33b5ef521bb89788ac
amount: 1000000
inputs_cnt: 0
inputs_count: 0
outputs_cnt: 0
outputs_count: 0
lock_time: 0
version: 0
Request output 1 on Tx:8742badeb461c3502f0a84c9df41b73eda7e88b978aa323aa8871c108df27e0e
< Message:TxRequest
requestType_=TXOUTPUT
details_=
request_index: 1
tx_hash: 8742badeb461c3502f0a84c9df41b73eda7e88b978aa323aa8871c108df27e0e
serialized_=
serialized_size: 0
serialized_tx:
signature_index: 0
signature:
Output 1 on Tx:8742badeb461c3502f0a84c9df41b73eda7e88b978aa323aa8871c108df27e0e has amount 324606713 Script program is 76a9143b0d3dc843fcce054271a7498d63f555548b16af88ac
> Message:TxAck
tx_=
bin_outputs_count: 1
script_pubkey: 76a9143b0d3dc843fcce054271a7498d63f555548b16af88ac
amount: 324606713
inputs_cnt: 0
inputs_count: 0
outputs_cnt: 0
outputs_count: 0
lock_time: 0
version: 0
Request input 0 on proposed Tx
< Message:TxRequest
requestType_=TXINPUT
details_=
request_index: 0
tx_hash:
serialized_=
serialized_size: 0
serialized_tx:
signature_index: 0
signature:
Input 0 on proposed Tx has 1 input of type SPENDADDRESS from Tx:8742badeb461c3502f0a84c9df41b73eda7e88b978aa323aa8871c108df27e0e
> Message:TxAck
tx_=
bin_outputs_count: 0
inputs_cnt: 0
inputs_count: 1
prev_hash: 8742badeb461c3502f0a84c9df41b73eda7e88b978aa323aa8871c108df27e0e
prev_index: 0
script_type: SPENDADDRESS
outputs_cnt: 0
outputs_count: 0
lock_time: 0
version: 0
Request output 0 on proposed Tx
< Message:TxRequest
requestType_=TXOUTPUT
details_=
request_index: 0
tx_hash:
serialized_=
serialized_size: 0
serialized_tx:
signature_index: 0
signature:
Output 0 on proposed Tx pays 900000 to 189azcVcq5EDhXhRjAB9bt17g64KeXqidW
> Message:TxAck
tx_=
bin_outputs_count: 0
inputs_cnt: 0
inputs_count: 0
outputs_cnt: 0
outputs_count: 1
address_bytes: 313839617a63566371354544685868526a414239627431376736344b655871696457
address: 189azcVcq5EDhXhRjAB9bt17g64KeXqidW
address_n_count: 0
amount: 900000
script_type: PAYTOADDRESS
lock_time: 0
version: 0
Display a button request notification (confirm output)
< Message:ButtonRequest
code_=ButtonRequest_ConfirmOutput
data_=
ACK
> Message:ButtonAck
Request output 1 on proposed Tx
< Message:TxRequest
requestType_=TXOUTPUT
details_=
request_index: 1
tx_hash:
serialized_=
serialized_size: 0
serialized_tx:
signature_index: 0
signature:
Output 1 on proposed Tx pays 100000 to 13pTZ2yZr6uY4Hw5mtvczLzvAbvhFkQAAc
> Message:TxAck
tx_=
bin_outputs_count: 0
inputs_cnt: 0
inputs_count: 0
outputs_cnt: 0
outputs_count: 1
address_bytes: 313370545a32795a72367559344877356d7476637a4c7a7641627668466b51414163
address: 13pTZ2yZr6uY4Hw5mtvczLzvAbvhFkQAAc
address_n_count: 0
amount: 100000
script_type: PAYTOADDRESS
lock_time: 0
version: 0
Display a button request notification (confirm output)
< Message:ButtonRequest
code_=ButtonRequest_ConfirmOutput
data_=
ACK
> Message:ButtonAck
Display a button request notification (confirm sign)
< Message:ButtonRequest
code_=ButtonRequest_SignTx
data_=
ACK
> Message:ButtonAck
Here is the proposed Tx payload partially serialized with tx output 0 and the signature for input 0
< Message:TxRequest
requestType_=TXOUTPUT
details_=
request_index: 0
tx_hash:
serialized_=
serialized_size: 229
serialized_tx: 01000000010e7ef28d101c87a83a32aa78b9887eda3eb741dfc9840a2f50c361b4deba4287000000006a473044022010d8e5b0b3800bca7a047bd08dce18d66b8f2930f8c99d666203ef5be7608b0f02201ed6594ce1bc03b6416b8b4411909082f20b70ac6e71a2cb60b097d5286cce9e012102bc8398d00c6ca116c8ce18ee0a4be7c004d679e880a865b75db866a4e23481dfffffffff
signature_index: 0
signature: 3044022010d8e5b0b3800bca7a047bd08dce18d66b8f2930f8c99d666203ef5be7608b0f02201ed6594ce1bc03b6416b8b4411909082f20b70ac6e71a2cb60b097d5286cce9e
ACK receipt of partially serialized Tx
> Message:TxAck
tx_=
bin_outputs_count: 0
inputs_cnt: 0
inputs_count: 0
outputs_cnt: 0
outputs_count: 0
lock_time: 0
version: 0
Here is the proposed Tx partially serialized with tx output 1
< Message:TxRequest
requestType_=TXOUTPUT
details_=
request_index: 1
tx_hash:
serialized_=
serialized_size: 37
serialized_tx: 02a0860100000000001976a9141ee9f76e2d8d536ec035601c2b8ef4e28cf50b9888ac
signature_index: 0
signature:
ACK receipt of partial serialized Tx
Message:TxAck@cc5c38[
tx_=
bin_outputs_count: 0
inputs_cnt: 0
inputs_count: 0
outputs_cnt: 0
outputs_count: 0
lock_time: 0
version: 0
Signing workflow is finished so this is the final part of the serialized Tx
< Message:TxRequest@1ddb0af[
requestType_=TXFINISHED
details_=
request_index: 0
tx_hash:
serialized_=
serialized_size: 40
serialized_tx: a0860100000000001976a9141ee9f76e2d8d536ec035601c2b8ef4e28cf50b9888ac00000000
signature_index: 0
signature:
Overall the signed serialized transaction becomes 01000000010e7ef28d101c87a83a32aa78b9887eda3eb741dfc9840a2f50c361b4deba4287000000006a473044022010d8e5b0b3800bca7a047bd08dce18d66b8f2930f8c99d666203ef5be7608b0f02201ed6594ce1bc03b6416b8b4411909082f20b70ac6e71a2cb60b097d5286cce9e012102bc8398d00c6ca116c8ce18ee0a4be7c004d679e880a865b75db866a4e23481dfffffffff02a0860100000000001976a9141ee9f76e2d8d536ec035601c2b8ef4e28cf50b9888aca0860100000000001976a9141ee9f76e2d8d536ec035601c2b8ef4e28cf50b9888ac00000000
and the input 0 signature is
3044022010d8e5b0b3800bca7a047bd08dce18d66b8f2930f8c99d666203ef5be7608b0f02201ed6594ce1bc03b6416b8b4411909082f20b70ac6e71a2cb60b097d5286cce9e
To check the validity of the transaction online tools such as Blockchain.info decode tx are available.