Skip to content

Conversation

@dimxy
Copy link
Collaborator

@dimxy dimxy commented Oct 8, 2025

Past PR #2331 added support for unconfirmed notes handling to prevent spent notes reuse and show unconfirmed change notes as unspendable balance. To implement that, PR 2331 added a locked notes DB.
However, that PR added support only for swap transactions, so if a withdrawal is called before or during a swap (while spent notes are not confirmed yet) errors like 18: bad-txns-joinsplit-requirements-not-met may occur when withdrawal and swap transactions are sent to the chain.

This PR adds support for the locked notes DB for zcoin withdrawals as well. The init_withdraw RPC now returns array of rseeds values which are used to access the locked notes DB. Also the init_withdraw RPC returns received_by_me decimal amount which is used to store change value in the locked notes DB. Both rseeds and received_by_me values should be passed along with the transaction in hex to the RPC sending the transaction into the network.

Breaking change
To send zcoin transaction into the network a new z_send_raw_transaction RPC must be used, instead of the old "send_raw_transaction". The z_send_raw_transaction RPC has more parameters:

curl --url "http://127.0.0.1:7783" --data '{ 
  "userpass": "...",
  "mmrpc":"2.0",
  "id": 0,
  "method": "z_send_raw_transaction",
  "params": {
     "coin": "ZOMBIE",
     "rseeds":  [ "0x123..ab4", "0xbcd..789" ], 
     "received_by_me": "123456.7890",
     "tx_hex": "0xabc..123"
  }
}'

The "rseeds", "received_by_me", "tx_hex" fields are returned by init_withdraw RPC.

TODO:
Will we ever support ZIP 32? For future support we could add AccountId field into the locked notes DB.

dimxy added 5 commits October 8, 2025 16:36
* dev:
  fix(TPU): correct dexfee in check balance to prevent swap failures (#2600)
  fix(tests): fix/remove kmd rewards failing test (#2633)
  chore(ci): bump CI container image to debian bullseye-slim to match dev (#2641)
  chore(release): add changelog entries for v2.5.2-beta (#2639)
  chore(release): bump mm2 version to 2.5.2-beta (#2638)
  feat(ci): add macos universal2 build (#2628)
  fix(metrics): remove memory_db size metric (#2632)
  chore(rust 1.90): make CI clippy/fmt pass
  Revert "fix(ordermatch): ignore loop-back; clear on null root; reject stale keep-alives (#2580)"
  Revert "fix(orderbook): validate roots before commit (#2605)"
@dimxy dimxy requested a review from shamardy October 8, 2025 15:33
@dimxy dimxy self-assigned this Oct 8, 2025
@dimxy dimxy added priority: medium Moderately important tasks that should be completed but are not urgent. bug: wallet labels Oct 8, 2025
@dimxy dimxy marked this pull request as ready for review October 8, 2025 16:44
@smk762 smk762 added the status: pending docs Adding this label will automatically open an issue in the docs repo label Oct 16, 2025
Comment on lines +2166 to +2170
impl ZCoin {
#[cfg(feature = "run-docker-tests")]
pub async fn withdraw_for_tests(&self, req: WithdrawRequest) -> Result<TransactionDetails, MmError<WithdrawError>> {
if req.fee.is_some() {
return MmError::err(WithdrawError::UnsupportedError(
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think the reason for not using the other init_withdraw/status_withdraw is that it's task managed and need an rpc and a MarketMakerIt to start?

can't we call init_withdraw here and provide a dummy task_handle just for processing this task and polling the status?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I'd like to.
I remember in the past I once tried to create a dummy task handle but that would have required too much extra code and some task manager refactoring. I was not sure it was worth it then and now I did not go that way too.

Comment on lines +2504 to +2514
/// 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,
}
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

Comment on lines +2571 to +2572
/// List of rseeds, for Zcoin
pub rseeds: Option<Vec<String>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is it Optional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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

Copy link
Collaborator

Choose a reason for hiding this comment

The 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 TransactionDetails (not in this PR). cc @shamardy


/// Request to send zcoin raw transaction with extra parameters
#[derive(Clone, Debug, Deserialize)]
pub struct ZcoinSendRawTransactionRequest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo fix:

Suggested change
pub struct ZcoinSendRawTransactionRequest {
pub struct ZCoinSendRawTransactionRequest {

@github-actions
Copy link

@shamardy
Please review it again.

@github-actions github-actions bot added the [] label Nov 30, 2025
@shamardy shamardy removed the [] label Dec 1, 2025
@github-actions
Copy link

github-actions bot commented Dec 3, 2025

@shamardy
Please review it again.

@github-actions github-actions bot added the [] label Dec 3, 2025
@github-actions
Copy link

github-actions bot commented Dec 5, 2025

@shamardy
Please review it again.

@shamardy shamardy removed the [] label Dec 9, 2025
@github-actions
Copy link

@shamardy
Please review it again.

@github-actions github-actions bot added the [] label Dec 11, 2025
@github-actions
Copy link

@shamardy
Please review it again.

1 similar comment
@github-actions
Copy link

@shamardy
Please review it again.

@github-actions
Copy link

@shamardy
Please review it again.

5 similar comments
@github-actions
Copy link

@shamardy
Please review it again.

@github-actions
Copy link

@shamardy
Please review it again.

@github-actions
Copy link

@shamardy
Please review it again.

@github-actions
Copy link

@shamardy
Please review it again.

@github-actions
Copy link

github-actions bot commented Jan 2, 2026

@shamardy
Please review it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.7.0-beta bug: wallet priority: medium Moderately important tasks that should be completed but are not urgent. status: pending docs Adding this label will automatically open an issue in the docs repo []

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants