Skip to content

Commit

Permalink
Change mintlayer sing tx response message
Browse files Browse the repository at this point in the history
  • Loading branch information
OBorce committed Nov 14, 2024
1 parent b88b27e commit 64d46a0
Show file tree
Hide file tree
Showing 7 changed files with 391 additions and 221 deletions.
16 changes: 11 additions & 5 deletions common/protob/messages-mintlayer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ message MintlayerSignTx {
message MintlayerTxRequest {
optional MintlayerRequestType request_type = 1; // what should be filled in TxAck message?
optional MintlayerTxRequestDetailsType details = 2; // request for tx details
repeated MintlayerTxRequestSerializedType serialized = 3; // serialized data and request for next
optional MintlayerTxRequestSerializedType serialized = 3; // serialized data and request for next
/**
* Type of information required by transaction signing process
*/
Expand All @@ -104,19 +104,25 @@ message MintlayerTxRequest {
optional bytes tx_hash = 2; // tx_hash of requested transaction
}
/**
* Structure representing request details
* Structure representing a single signature
*/
message MintlayerSignature {
required bytes signature = 1; // a single signature
optional uint32 multisig_idx = 2; // in case of multisig the index of the key
}
/**
* Structure representing all of the signatures for a single input, can be multiple for a multisig address
*/
message MintlayerSignatures {
optional uint32 signature_index = 1; // 'signature' field contains signed input of this index
repeated MintlayerSignature signatures = 2; // all signatures for an input
}
/**
* Structure representing serialized data
*/
message MintlayerTxRequestSerializedType {
optional uint32 signature_index = 1; // 'signature' field contains signed input of this index
repeated MintlayerSignature signatures = 2; // signature of the signature_index input
optional bytes serialized_tx = 3; // part of serialized and signed transaction
repeated MintlayerSignatures signatures = 1; // signature of the signature_index input
optional bytes serialized_tx = 2; // the serialized tx
}
}

Expand Down
5 changes: 3 additions & 2 deletions core/src/apps/mintlayer/sign_tx/signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from trezor.crypto.hashlib import blake2b
from trezor.messages import (
MintlayerSignature,
MintlayerSignatures,
MintlayerSignTx,
MintlayerTxInput,
MintlayerTxOutput,
Expand Down Expand Up @@ -510,15 +511,15 @@ async def step6_finish(
self, signatures: List[List[Tuple[bytes, int | None]]]
) -> None:
sigs = [
MintlayerTxRequestSerializedType(
MintlayerSignatures(
signature_index=i,
signatures=[
MintlayerSignature(signature=s[0], multisig_idx=s[1]) for s in sigs
],
)
for i, sigs in enumerate(signatures)
]
self.tx_req.serialized = sigs
self.tx_req.serialized = MintlayerTxRequestSerializedType(signatures=sigs)
await helpers.request_tx_finish(self.tx_req)


Expand Down
22 changes: 18 additions & 4 deletions core/src/trezor/messages.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 20 additions & 6 deletions python/src/trezorlib/messages.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions python/src/trezorlib/mintlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def sign_tx(
version: Optional["int"] = 1,
serialize: Optional["bool"] = True,
chunkify: Optional["bool"] = None,
) -> List[messages.MintlayerTxRequestSerializedType]:
) -> List[messages.MintlayerSignatures]:
res = client.call(
messages.MintlayerSignTx(
outputs_count=len(outputs),
Expand All @@ -95,7 +95,10 @@ def sign_tx(
R = messages.MintlayerRequestType
while isinstance(res, messages.MintlayerTxRequest):
if res.request_type == R.TXFINISHED:
return list(res.serialized)
if res.serialized:
return list(res.serialized.signatures)
else:
return []

if res.request_type == R.TXINPUT and res.details is not None:
assert res.details.request_index is not None
Expand Down
1 change: 1 addition & 0 deletions rust/trezor-client/src/client/mintlayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ impl Trezor {
MintlayerRequestType::TXFINISHED => {
return Ok(response
.serialized
.signatures
.iter()
.map(|s| {
s.signatures
Expand Down
Loading

0 comments on commit 64d46a0

Please sign in to comment.