+
Skip to content

Conversation

dolanbernard
Copy link
Contributor

  • Adding TxOutContext struct to return TxOut, TxOutConfirmationNumber, and a shared secret from transaction builder add_output
  • Adding iOS native updates to expose TxOutContext to SDK
  • Adding Android native updates to expose TxOutContext to SDK

Motivation

This is needed for the SDKs to support Moby transaction history

Alex Voloshyn and others added 10 commits May 11, 2022 11:44
…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
Copy link
Contributor

@iamalwaysuncomfortable iamalwaysuncomfortable left a 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.

@samdealy samdealy self-requested a review May 12, 2022 17:49

/// Transaction output context is produced by add_output method
/// Used for receipt creation
#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Contributor Author

@dolanbernard dolanbernard May 12, 2022

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.

@cbeck88
Copy link
Contributor

cbeck88 commented May 12, 2022

I think this looks good in concept -- the only thing is, I think this should be the only version of add_output and add_change_output. That will lead to a large diff because there's a lot of code using the transaction builder, but I think that's okay. That's usually what we do when developing the transaction builder -- we allow breaking changes to happen to avoid at all costs having a confusing API

transaction_builder.add_input(input_credentials);

let (_txout, _confirmation) = transaction_builder
let _tx_out_context = transaction_builder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let _tx_out_context = transaction_builder
transaction_builder

Comment on lines 483 to +484
out_tx_out_confirmation_number: FfiMutPtr<McMutableBuffer>,
out_tx_out_shared_secret: FfiMutPtr<McMutableBuffer>,
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor

@cbeck88 cbeck88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@iamalwaysuncomfortable iamalwaysuncomfortable left a 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!

@dolanbernard dolanbernard merged commit e4f41d1 into candidate-1.2 May 16, 2022
@dolanbernard dolanbernard deleted the tx-builder-shared-secret branch May 16, 2022 20:25
@remoun
Copy link
Contributor

remoun commented May 16, 2022

We should merge this PR/branch into master, too

@jcape jcape added this to the 1.2.0 Release milestone May 17, 2022
briancorbin added a commit that referenced this pull request Jul 15, 2022
* 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 <remoun@mobilecoin.com>

* Update libmobilecoin/include/transaction.h

Co-authored-by: Remoun Metyas <remoun@mobilecoin.com>

* 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 <alexv@mobilecoin.com>
Co-authored-by: the-real-adammork <adammork@gmail.com>
Co-authored-by: Remoun Metyas <remoun@mobilecoin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载