-
Notifications
You must be signed in to change notification settings - Fork 153
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
TransactionBuilder TxOutContext #1966
Conversation
…lly included in its import. Make individual variables in new struct public (may not be optimal fix). Update binding functions in libmobilecoin to use the new context based add_change_output/add_output calls to the transaction builder, and add a new "out" parameter to each of those ffi bindings so the SDK can consume the shared_secret.
…s for shared_secret in the add_change and add_ouput ffi binding functions.
TransactionBuilder add_output returns TxOutContext
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 believe this is too large of a change to transaction builder & that we should probably not be sending the txout shared secret in a struct. Suggested some possible alternatives, would be happy to open up the discussion more.
@@ -38,6 +38,22 @@ impl TxOutputsOrdering for DefaultTxOutputsOrdering { | |||
} | |||
} | |||
|
|||
/// Transaction output context is produced by add_output method | |||
/// Used for receipt creation | |||
#[allow(dead_code)] |
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.
Why is this needed?
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.
Without that compilation fails due to the shared secret being dead code.
Actually it looks like making it public also fixed that. I'll remove it.
I think this looks good in concept -- the only thing is, I think this should be the only version of |
Co-authored-by: Remoun Metyas <[email protected]>
Co-authored-by: Remoun Metyas <[email protected]>
…oinfoundation/mobilecoin into tx-builder-shared-secret
@@ -970,7 +989,7 @@ pub mod transaction_builder_tests { | |||
get_input_credentials(block_version, amount, &sender, &fog_resolver, &mut rng); | |||
transaction_builder.add_input(input_credentials); | |||
|
|||
let (_txout, _confirmation) = transaction_builder | |||
let _tx_out_context = transaction_builder |
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.
let _tx_out_context = transaction_builder | |
transaction_builder |
out_tx_out_confirmation_number: FfiMutPtr<McMutableBuffer>, | ||
out_tx_out_shared_secret: FfiMutPtr<McMutableBuffer>, |
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.
Since we're switching TransactionBuilder::add_*output
to return TxOutContext
, would it make sense to similarly make these FFI add_output
methods return the whole TxOutContext
, replacing these 2 out pointers?
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.
yes, using the second out pointer was my idea, but I think returning a whole TxOutContext
would be better.
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.
Ill work on a commit to make this change
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.
LGTM
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.
Much better, cleared by me!
We should merge this PR/branch into |
* add_output returns TxOutContext * Overloading modified tx builder functions for compatibility * Add TxOutContext to transaction_std lib.rs so its scope is automatically included in its import. Make individual variables in new struct public (may not be optimal fix). Update binding functions in libmobilecoin to use the new context based add_change_output/add_output calls to the transaction builder, and add a new "out" parameter to each of those ffi bindings so the SDK can consume the shared_secret. * add documentation to TxOutContext variables. Change copy out semantics for shared_secret in the add_change and add_ouput ffi binding functions. * Android Bindings TxOutContext TransactionBuilder add_output returns TxOutContext * Removing comments * Lint * Lint * Fixing test * Fixing test * Remove duplicated add_output and add_change_output * Update libmobilecoin/include/transaction.h Co-authored-by: Remoun Metyas <[email protected]> * Update libmobilecoin/include/transaction.h Co-authored-by: Remoun Metyas <[email protected]> * Struct deconstruction to fix build error * Fixing imports * Deconstructing more structs * Fixing syntax * Fixing tests * Remove references to old new functions * Fixing struct deconstruction * Test fix * Test fixes * Imports * Fixing test imports * Lint Co-authored-by: Alex Voloshyn <[email protected]> Co-authored-by: the-real-adammork <[email protected]> Co-authored-by: Remoun Metyas <[email protected]>
Motivation
This is needed for the SDKs to support Moby transaction history