-
Notifications
You must be signed in to change notification settings - Fork 221
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
feat!: add payment id #6340
feat!: add payment id #6340
Conversation
Test Results (CI) 3 files 120 suites 38m 59s ⏱️ Results for commit 7ad53c8. ♻️ This comment has been updated with latest results. |
Test Results (Integration tests) 2 files + 2 1 errors 9 suites +9 10m 46s ⏱️ + 10m 46s For more details on these parsing errors and failures, see this check. Results for commit 7ad53c8. ± Comparison against base commit 0fd2efe. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, some comments relating to the interpretation of the requirement for a payment ID.
let payment_id_u64: u64 = payment_id_hex | ||
.parse::<u64>() | ||
.map_err(|_| UiError::HexError("Could not convert payment_id to bytes".to_string()))?; | ||
let payment_id = PaymentId::U64(payment_id_u64); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should allow 256 bytes, not only 8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just UI support for now, in CW to only support u64
let payment_id_u64: u64 = payment_id_hex | ||
.parse::<u64>() | ||
.map_err(|_| UiError::HexError("Could not convert payment_id to bytes".to_string()))?; | ||
let payment_id = PaymentId::U64(payment_id_u64); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto size
pub enum PaymentId { | ||
Zero, | ||
U32(u32), | ||
U64(u64), | ||
U256(U256), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the brackets are a good idea instead of a perfect variable length.
- I propose these brackets:
- 8 bytes
- 16 bytes
- 32 bytes
- 16-byte increments up to 256 bytes (48, 64, 80, ..., 256)
@@ -397,6 +404,7 @@ impl ConsensusConstants { | |||
faucet_value: 0.into(), | |||
transaction_weight: TransactionWeight::latest(), | |||
max_script_byte_size: 2048, | |||
max_encrypted_data_byte_size: 32, // U256 size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be the current EncryptedData::data: [u8; SIZE_TOTAL]
plus 256 bytes,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was debating about making it max_encrypted_data_byte_size or max_payment_id_size
Its currently max payment id in effect, but not name
@@ -461,6 +469,7 @@ impl ConsensusConstants { | |||
faucet_value: 0.into(), // IGOR_FAUCET_VALUE.into(), | |||
transaction_weight: TransactionWeight::v1(), | |||
max_script_byte_size: 2048, | |||
max_encrypted_data_byte_size: 32, // U256 size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto size
f5c471a
to
c8fa3de
Compare
applications/minotari_console_wallet/src/automation/commands.rs
Outdated
Show resolved
Hide resolved
applications/minotari_console_wallet/src/grpc/wallet_grpc_server.rs
Outdated
Show resolved
Hide resolved
@@ -29,6 +29,7 @@ pub struct SendTab { | |||
send_input_mode: SendInputMode, | |||
show_contacts: bool, | |||
to_field: String, | |||
payment_id_field: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might be good in future to include a drop down for "Custom Text", "Custom binary", "Sender Address"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as well as some other options in future. Exchanges might want a specific field in here.
let mut bytes = Zeroizing::new([0u8; SIZE_VALUE + SIZE_MASK]); | ||
bytes.clone_from_slice(&encrypted_data.as_bytes()[SIZE_NONCE..SIZE_NONCE + SIZE_VALUE + SIZE_MASK]); | ||
let tag = Tag::from_slice(&encrypted_data.as_bytes()[SIZE_NONCE + SIZE_VALUE + SIZE_MASK..]); | ||
let tag = Tag::from_slice(&encrypted_data.as_bytes()[..SIZE_TAG]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch out for buffer overrun. Possibly fuzz this with quicktest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those should all be a constant size, and there min size checks
Co-authored-by: stringhandler <[email protected]>
Description --- Add payment id as buckets into encrypted data field Motivation and Context --- Allows wallets to send encrypted data via the block chain to other wallets --------- Co-authored-by: stringhandler <[email protected]>
let mut data = vec![0; bytes.len()]; | ||
data.copy_from_slice(bytes); | ||
Ok(Self { data }) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok(Self { data: bytes.to_vec() })
Description
Add payment id as buckets into encrypted data field
Motivation and Context
Allows wallets to send encrypted data via the block chain to other wallets