From 91a89ee6eb1b0e1a1a8dee7a77ed3e1d3532a33b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 31 Aug 2025 08:24:50 +0000 Subject: [PATCH] Refactor Salvium asset symbol setting to use height-based logic Co-authored-by: t1amak <57602242+t1amak@users.noreply.github.com> --- lib/paymentProcessor.js | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/lib/paymentProcessor.js b/lib/paymentProcessor.js index ab89be5..0e32ac2 100644 --- a/lib/paymentProcessor.js +++ b/lib/paymentProcessor.js @@ -284,14 +284,31 @@ function processSalviumAwarePayments(currentHeight) { let rpcCommand = "transfer"; let rpcRequest = transferCmd.rpc; - if (config.symbol === 'SAL1') { - transferCmd.rpc.destinations.forEach(destination => { - destination.asset_type = "SAL1"; - }); - transferCmd.rpc.source_asset = "SAL1"; - transferCmd.rpc.dest_asset = "SAL1"; - transferCmd.rpc.tx_type = 3; - } + // Handle Salvium asset type settings based on height + if (utils.isSalviumEnabled()) { + // Guard against missing structures + if (transferCmd && transferCmd.rpc) { + // Compute effective symbol by height + let transitionHeight = config.salvium && config.salvium.heights && config.salvium.heights.audit_phase1 + ? config.salvium.heights.audit_phase1 + : 815; + let effectiveSymbol = (currentHeight >= transitionHeight) ? 'SAL1' : 'SAL'; + + // Set asset fields for all destinations + if (transferCmd.rpc.destinations && Array.isArray(transferCmd.rpc.destinations)) { + transferCmd.rpc.destinations.forEach(destination => { + destination.asset_type = effectiveSymbol; + }); + } + + // Set source and destination assets + transferCmd.rpc.source_asset = effectiveSymbol; + transferCmd.rpc.dest_asset = effectiveSymbol; + + // Always set tx_type = 3 for Salvium (both phases) + transferCmd.rpc.tx_type = 3; + } + } if (daemonType === "bytecoin") {