Merge pull request #3 from t1amak/copilot/fix-a05d0f50-d441-4e59-a79a-9d995098a487

Refactor Salvium asset symbol setting to use height-based logic instead of hardcoded config check
This commit is contained in:
gh14
2025-08-31 10:35:04 +02:00
committed by GitHub

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