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

Add script_pubkey field to TxInput message #1857

Merged
merged 1 commit into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion common/protob/messages-bitcoin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ message TxAck {
optional bytes orig_hash = 16; // tx_hash of the original transaction where this input was spent (used when creating a replacement transaction)
optional uint32 orig_index = 17; // index of the input in the original transaction (used when creating a replacement transaction)
optional DecredStakingSpendType decred_staking_spend = 18; // if not None this holds the type of stake spend: revocation or stake generation
optional bytes script_pubkey = 19; // scriptPubKey of the previous output spent by this input, only set of EXTERNAL inputs
}
/**
* Structure representing compiled transaction output
Expand Down Expand Up @@ -351,6 +352,7 @@ message TxInput {
optional bytes orig_hash = 16; // tx_hash of the original transaction where this input was spent (used when creating a replacement transaction)
optional uint32 orig_index = 17; // index of the input in the original transaction (used when creating a replacement transaction)
optional DecredStakingSpendType decred_staking_spend = 18; // if not None this holds the type of stake spend: revocation or stake generation
optional bytes script_pubkey = 19; // scriptPubKey of the previous output spent by this input, only set of EXTERNAL inputs
}

/** Data type for transaction output to be signed.
Expand Down Expand Up @@ -399,7 +401,7 @@ message PrevInput {
optional uint32 decred_tree = 9; // only for Decred

// fields that are in use, or have been in the past, in TxInputType
reserved 1, 6, 7, 8, 10, 11, 12, 13, 14, 15;
reserved 1, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19;
}

/** Data type for outputs of previous transactions.
Expand Down
1 change: 1 addition & 0 deletions core/.changelog.d/1857.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add script_pubkey field to TxInput message.
2 changes: 2 additions & 0 deletions core/src/trezor/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ class TxInput(protobuf.MessageType):
orig_hash: "bytes | None"
orig_index: "int | None"
decred_staking_spend: "DecredStakingSpendType | None"
script_pubkey: "bytes | None"

def __init__(
self,
Expand All @@ -662,6 +663,7 @@ def __init__(
orig_hash: "bytes | None" = None,
orig_index: "int | None" = None,
decred_staking_spend: "DecredStakingSpendType | None" = None,
script_pubkey: "bytes | None" = None,
) -> None:
pass

Expand Down
2 changes: 1 addition & 1 deletion docs/common/communication/bitcoin-signing.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ signing party hasn't signed their input yet (i.e., with two Trezors, one must si
so that the other can include a pre-signed input), they can instead provide a
[SLIP-19](https://github.com/satoshilabs/slips/blob/master/slip-0019.md)
ownership proof in the `ownership_proof` field, with optional commitment data in
`commitment_data`.
`commitment_data`. The `script_pubkey` field is required for all external inputs.

### Transaction output

Expand Down
1 change: 1 addition & 0 deletions legacy/firmware/.changelog.d/1857.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add script_pubkey field to TxInput message.
2 changes: 1 addition & 1 deletion legacy/firmware/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define MSG_IN_ENCODED_SIZE (16 * 1024)

// Maximum size of a C struct containing a decoded incoming message.
#define MSG_IN_DECODED_SIZE (15 * 1024)
#define MSG_IN_DECODED_SIZE (16 * 1024)

// Buffer size for outgoing USB packets with headers.
#define MSG_OUT_BUFFER_SIZE (3 * 1024)
Expand Down
2 changes: 2 additions & 0 deletions legacy/firmware/protob/messages-bitcoin.options
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ TxInputType.witness max_size:109
TxInputType.ownership_proof max_size:171
TxInputType.commitment_data max_size:32
TxInputType.orig_hash max_size:32
TxInputType.script_pubkey max_size:520

TxOutputType.address max_size:130
TxOutputType.address_n max_count:8
Expand Down Expand Up @@ -62,6 +63,7 @@ TxInput.witness max_size:109
TxInput.ownership_proof max_size:171
TxInput.commitment_data max_size:32
TxInput.orig_hash max_size:32
TxInput.script_pubkey max_size:520

TxOutput.address max_size:130
TxOutput.address_n max_count:8
Expand Down
1 change: 1 addition & 0 deletions python/.changelog.d/1857.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add script_pubkey field to TxInput message.
6 changes: 6 additions & 0 deletions python/src/trezorlib/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,7 @@ class TxInput(protobuf.MessageType):
16: protobuf.Field("orig_hash", "bytes", repeated=False, required=False),
17: protobuf.Field("orig_index", "uint32", repeated=False, required=False),
18: protobuf.Field("decred_staking_spend", "DecredStakingSpendType", repeated=False, required=False),
19: protobuf.Field("script_pubkey", "bytes", repeated=False, required=False),
}

def __init__(
Expand All @@ -1217,6 +1218,7 @@ def __init__(
orig_hash: Optional["bytes"] = None,
orig_index: Optional["int"] = None,
decred_staking_spend: Optional["DecredStakingSpendType"] = None,
script_pubkey: Optional["bytes"] = None,
) -> None:
self.address_n = address_n if address_n is not None else []
self.prev_hash = prev_hash
Expand All @@ -1233,6 +1235,7 @@ def __init__(
self.orig_hash = orig_hash
self.orig_index = orig_index
self.decred_staking_spend = decred_staking_spend
self.script_pubkey = script_pubkey


class TxOutput(protobuf.MessageType):
Expand Down Expand Up @@ -1650,6 +1653,7 @@ class TxInputType(protobuf.MessageType):
16: protobuf.Field("orig_hash", "bytes", repeated=False, required=False),
17: protobuf.Field("orig_index", "uint32", repeated=False, required=False),
18: protobuf.Field("decred_staking_spend", "DecredStakingSpendType", repeated=False, required=False),
19: protobuf.Field("script_pubkey", "bytes", repeated=False, required=False),
}

def __init__(
Expand All @@ -1670,6 +1674,7 @@ def __init__(
orig_hash: Optional["bytes"] = None,
orig_index: Optional["int"] = None,
decred_staking_spend: Optional["DecredStakingSpendType"] = None,
script_pubkey: Optional["bytes"] = None,
) -> None:
self.address_n = address_n if address_n is not None else []
self.prev_hash = prev_hash
Expand All @@ -1686,6 +1691,7 @@ def __init__(
self.orig_hash = orig_hash
self.orig_index = orig_index
self.decred_staking_spend = decred_staking_spend
self.script_pubkey = script_pubkey


class TxOutputBinType(protobuf.MessageType):
Expand Down