-
Notifications
You must be signed in to change notification settings - Fork 80
Problem:(CRO-557) no way to import transactions (without a view key) #695
Conversation
Codecov Report
@@ Coverage Diff @@
## master #695 +/- ##
==========================================
- Coverage 69.71% 69.16% -0.56%
==========================================
Files 131 131
Lines 16745 16886 +141
==========================================
+ Hits 11674 11679 +5
- Misses 5071 5207 +136
|
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.
looks good (I haven't tested it yet though), just a bit more descriptive comments would be helpful + as this is a bigger feature, it'll be good to update CHANGELOG.md
that this feature was added (just put a note at the top with a header ## v0.1.1 (unreleased)
)
client-core/src/wallet.rs
Outdated
@@ -185,6 +185,9 @@ pub trait WalletClient: Send + Sync { | |||
|
|||
/// Broadcasts a transaction to Crypto.com Chain | |||
fn broadcast_transaction(&self, tx_aux: &TxAux) -> Result<BroadcastTxResponse>; | |||
|
|||
/// Get the plain transaction |
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 comment just repeats the name, so not that helpful -- it'd be better to include some information that one can't read from the type signature... e.g. under what circumstances it could fail or what kind of String
it returns (it seems to return base64-encoded ?)
client-common/src/transaction.rs
Outdated
pub struct TransactionInfo { | ||
/// enum Transaction type | ||
pub tx: Transaction, | ||
/// block height of the tx |
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 guess block height when the transaction was committed?
client-cli/src/command.rs
Outdated
about = "Download a plain transaction by a given transaction id" | ||
)] | ||
DownloadTx { | ||
#[structopt(name = "name", short, long, help = "Name of wallet")] | ||
name: String, | ||
#[structopt(name = "tx_id", short, long, help = "transaction id")] | ||
tx_id: String, | ||
}, | ||
|
||
#[structopt( | ||
name = "sync_tx", | ||
about = "Synchronize a plain transaction that view key not included" |
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.
in about
, it may good to list the transaction types this applies to
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.
also how about
./client-cli transaction download --name a
sub-command of transaction
download_tx is too long to type
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, I think so.
overall, lgtm, |
68d1b35
to
5e01082
Compare
@@ -29,4 +30,8 @@ impl WalletTransactionBuilder for UnauthorizedWalletTransactionBuilder { | |||
fn obfuscate(&self, _: SignedTransaction) -> Result<TxAux> { | |||
Err(ErrorKind::PermissionDenied.into()) | |||
} | |||
|
|||
fn decrypt_tx(&self, _txid: TxId, _private_key: &PrivateKey) -> Result<Transaction> { |
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.
The only two methods of trait TransactionObfuscation
get re-exported by trait WalletTransactionBuilder
, it doesn't feel right ;D
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 if I don't use the WalletTransactionBuilder
, I have to put a TransactionObfuscation
implied object into the DefaultWalletClient
and I have to deal with the new_read_only
function where I have to create a new mock transaction obfuscation like UnauthorizedObfuscation
and make impl the TransactionObfuscation
, which is much expensive.
client-core/src/wallet/syncer.rs
Outdated
@@ -374,6 +381,52 @@ impl<'a, S: SecureStorage, C: Client, D: TxDecryptor> WalletSyncerImpl<'a, S, C, | |||
Ok(()) | |||
} | |||
|
|||
fn sync_tx(&mut self, tx_str: &str) -> Result<Coin> { |
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 guess this is perfectly ok to write as a separate function, it's not "sync".
client-core/src/wallet/syncer.rs
Outdated
spent_flags?, | ||
) | ||
.chain(|| (ErrorKind::InvalidInput, "import error"))?; | ||
self.save(&memento)?; |
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 the side-effect of implementing this feature in Syncer
, save
will also write SyncState
which is not used by this feature, but if there is concurrently running syncing process, it will override 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.
I'll make an individual function called update_status
and use it in save
} | ||
|
||
/// update WalletStateMemento when import a transaction | ||
pub(crate) fn import_transaction( |
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.
Maybe we should rename syncer_logic
to wallet_logic
or something when it's function goes beyond syncing, to prevent future confusion.
client-rpc/src/rpc/wallet_rpc.rs
Outdated
@@ -64,6 +64,9 @@ pub trait WalletRpc: Send + Sync { | |||
|
|||
#[rpc(name = "wallet_transactions")] | |||
fn transactions(&self, request: WalletRequest) -> Result<Vec<TransactionChange>>; | |||
|
|||
#[rpc(name = "wallet_downloadTransaction")] | |||
fn plain_transaction(&self, request: WalletRequest, txid: String) -> Result<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.
How about sync_tx
-> importTransaction
, downloadTransaction
-> exportTransaction
.
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.
good
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.
there are some merge conflicts with master
CHANGELOG.md
Outdated
## v0.1.1 | ||
|
||
### Features | ||
* *client*: export and import transaction -- transaction in which the receiver's view key not included can be exported by a give transaction id (the sender can list transactions and find it), getting a base64 encoded plain transaction string and the receiver can import the string into wallet. |
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.
master is already unreleased 0.2, so perhaps no "0.1.1", just move the features paragraph under 0.2
7234ab9
to
82e763e
Compare
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 seems it fails to compile after merges
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.
looks all right -- can you squash the commits?
the build fail is now due to clippy changes -- I fixed it in f3eed40 so don't worry about that
5590e9b
to
6dc50ab
Compare
bors r+ |
This PR was included in a batch with a merge conflict, it will be automatically retried |
Merge conflict |
6dc50ab
to
6207d2c
Compare
solution: - add a interface `export_tx` for sender to download the the transaction - add a interface `import_tx` for receiver to import the transaction and get the output UTXO
6207d2c
to
91afe97
Compare
bors r+ |
695: Problem:(CRO-557) no way to import transactions (without a view key) r=devashishdxt a=linfeng-crypto solution: - add a interface `export_tx` for sender to get the plain transaction - add a interface `import_tx` for receiver to import the plain transaction and get the output UTXO 740: Problem:(CRO-661) not enough logging in debug enclave execution r=devashishdxt a=linfeng-crypto solution: add some logs. Co-authored-by: linfeng <linfeng@crypto.com>
Build failed (retrying...) |
695: Problem:(CRO-557) no way to import transactions (without a view key) r=devashishdxt a=linfeng-crypto solution: - add a interface `export_tx` for sender to get the plain transaction - add a interface `import_tx` for receiver to import the plain transaction and get the output UTXO Co-authored-by: linfeng <linfeng@crypto.com>
solution:
export_tx
for sender to get the plain transactionimport_tx
for receiver to import the plain transaction and get the output UTXO