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") {