Refactor Salvium asset symbol setting to use height-based logic

Co-authored-by: t1amak <57602242+t1amak@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-08-31 08:24:50 +00:00
parent b815a0f419
commit 91a89ee6eb

View File

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