-
Notifications
You must be signed in to change notification settings - Fork 117
fix(zcoin): add locked notes support for withdrawals #2644
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
base: dev
Are you sure you want to change the base?
Changes from all commits
001a2ef
14e0024
8fe5b5f
5116e1a
590a0fb
84937a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -406,6 +406,7 @@ where | |
| kmd_rewards: None, | ||
| transaction_type: Default::default(), | ||
| memo: None, | ||
| rseeds: None, | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -320,9 +320,9 @@ pub type TradePreimageFut<T> = Box<dyn Future<Item = T, Error = MmError<TradePre | |
| pub type CoinFindResult<T> = Result<T, MmError<CoinFindError>>; | ||
| pub type TxHistoryFut<T> = Box<dyn Future<Item = T, Error = MmError<TxHistoryError>> + Send>; | ||
| pub type TxHistoryResult<T> = Result<T, MmError<TxHistoryError>>; | ||
| pub type RawTransactionResult = Result<RawTransactionRes, MmError<RawTransactionError>>; | ||
| pub type RawTransactionResult = Result<SignRawTransactionRes, MmError<RawTransactionError>>; | ||
| pub type RawTransactionFut<'a> = | ||
| Box<dyn Future<Item = RawTransactionRes, Error = MmError<RawTransactionError>> + Send + 'a>; | ||
| Box<dyn Future<Item = SignRawTransactionRes, Error = MmError<RawTransactionError>> + Send + 'a>; | ||
| pub type RefundResult<T> = Result<T, MmError<RefundError>>; | ||
| /// Helper type used for swap transactions' spend preimage generation result | ||
| pub type GenPreimageResult<Coin> = MmResult<TxPreimageWithSig<Coin>, TxGenError>; | ||
|
|
@@ -438,13 +438,13 @@ impl HttpStatusCode for GetMyAddressError { | |
| } | ||
|
|
||
| #[derive(Deserialize)] | ||
| pub struct RawTransactionRequest { | ||
| pub struct GetRawTransactionRequest { | ||
| pub coin: String, | ||
| pub tx_hash: String, | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] | ||
| pub struct RawTransactionRes { | ||
| pub struct SignRawTransactionRes { | ||
| /// Raw bytes of signed transaction in hexadecimal string, this should be return hexadecimal encoded signed transaction for get_raw_transaction | ||
| pub tx_hex: BytesJson, | ||
| } | ||
|
|
@@ -2501,6 +2501,18 @@ impl KmdRewardsDetails { | |
| } | ||
| } | ||
|
|
||
| /// Request to send zcoin raw transaction with extra parameters | ||
| #[derive(Clone, Debug, Deserialize)] | ||
| pub struct ZcoinSendRawTransactionRequest { | ||
| coin: String, | ||
| /// List of rseeds used to create transaction notes, needed to lock sent notes properly | ||
| pub rseeds: Vec<String>, | ||
| /// Change amount | ||
| pub received_by_me: BigDecimal, | ||
| /// Serialized zcoin transaction | ||
| pub tx_hex: String, | ||
| } | ||
|
Comment on lines
+2504
to
+2514
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we put this in a better place, like RPC or ZCoin crates? |
||
|
|
||
| #[derive(Default, Clone, Debug, Deserialize, PartialEq, Serialize)] | ||
| pub enum TransactionType { | ||
| StakingDelegation, | ||
|
|
@@ -2534,7 +2546,7 @@ pub struct TransactionDetails { | |
| /// The amount spent from "my" address | ||
| spent_by_me: BigDecimal, | ||
| /// The amount received by "my" address | ||
| received_by_me: BigDecimal, | ||
| pub received_by_me: BigDecimal, | ||
| /// Resulting "my" balance change | ||
| my_balance_change: BigDecimal, | ||
| /// Block height | ||
|
|
@@ -2556,6 +2568,8 @@ pub struct TransactionDetails { | |
| #[serde(default)] | ||
| transaction_type: TransactionType, | ||
| memo: Option<String>, | ||
| /// List of rseeds, for Zcoin | ||
| pub rseeds: Option<Vec<String>>, | ||
|
Comment on lines
+2571
to
+2572
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This TransactionDetails struct is common for all coin types, so we just use Option for those fields which may be relevant only for some coin type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we encode this type anywhere? If not, we should make it generic enum that takes protocol-specific |
||
| } | ||
|
|
||
| #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] | ||
|
|
@@ -3602,7 +3616,7 @@ pub trait MmCoin: SwapOps + WatcherOps + MarketCoinOps + Send + Sync + 'static { | |
|
|
||
| fn withdraw(&self, req: WithdrawRequest) -> WithdrawFut; | ||
|
|
||
| fn get_raw_transaction(&self, req: RawTransactionRequest) -> RawTransactionFut<'_>; | ||
| fn get_raw_transaction(&self, req: GetRawTransactionRequest) -> RawTransactionFut<'_>; | ||
|
|
||
| fn get_tx_hex_by_hash(&self, tx_hash: Vec<u8>) -> RawTransactionFut<'_>; | ||
|
|
||
|
|
@@ -5435,7 +5449,7 @@ pub async fn withdraw(ctx: MmArc, req: WithdrawRequest) -> WithdrawResult { | |
| coin.withdraw(req).compat().await | ||
| } | ||
|
|
||
| pub async fn get_raw_transaction(ctx: MmArc, req: RawTransactionRequest) -> RawTransactionResult { | ||
| pub async fn get_raw_transaction(ctx: MmArc, req: GetRawTransactionRequest) -> RawTransactionResult { | ||
| let coin = lp_coinfind_or_err(&ctx, &req.coin).await.map_mm_err()?; | ||
| coin.get_raw_transaction(req).compat().await | ||
| } | ||
|
|
@@ -5472,6 +5486,17 @@ pub async fn sign_raw_transaction(ctx: MmArc, req: SignRawTransactionRequest) -> | |
| coin.sign_raw_tx(&req).await | ||
| } | ||
|
|
||
| pub async fn z_send_raw_transaction( | ||
| ctx: MmArc, | ||
| req: ZcoinSendRawTransactionRequest, | ||
| ) -> MmResult<String, RawTransactionError> { | ||
| let coin = lp_coinfind_or_err(&ctx, &req.coin).await.map_mm_err()?; | ||
| match coin { | ||
| MmCoinEnum::ZCoin(ref z_coin) => z_coin.z_send_raw_tx(req).await, | ||
| _ => MmError::err(RawTransactionError::NotImplemented { coin: req.coin }), | ||
| } | ||
| } | ||
|
|
||
| pub async fn remove_delegation(ctx: MmArc, req: RemoveDelegateRequest) -> DelegationResult { | ||
| let coin = lp_coinfind_or_err(&ctx, &req.coin).await.map_mm_err()?; | ||
|
|
||
|
|
||
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.
Typo fix: