// things: array of inputs or outputs. function sumAmount(things) { var sum = new Long(0); things.forEach((th) => { sum = sum.add(th.amount); }); return sum; }
public OnTerminateProcess(rawTerminationTime: string): void { ServerState.debug( `ServerState got the terminateProcess signal. rawTerminationTime : ${rawTerminationTime}` ) ;(async () => { const deserialized: sdk.com.amazon.whitewater.auxproxy.pbuffer.TerminateProcess = JSON.parse( rawTerminationTime ) if (deserialized == null) { // If termination time isn't sent from AuxProxy use now plus 5 minutes. let defaultTerminationTime = Long.fromNumber(Date.now()) defaultTerminationTime = defaultTerminationTime.add(270 * 1000) this.terminationTime = defaultTerminationTime.mul(10000) } else { /* TerminationTime coming from AuxProxy is seconds that have elapsed since Unix epoch time begins (00:00:00 UTC Jan 1 1970). * Since epoch time for dotNet starts at 0001-01-01T00:00:00 we need to create a DateTime at the beginning of Unix epoch time * and add the TerminationTime to that date. */ this.terminationTime = deserialized.terminationTime.mul(1000 * 10000) } this.processParameters!.OnProcessTerminate() })() }
sumAmount(tx.outputs).add(tx.inputs.length+tx.outputs.length))) { cb({code:tmsp.CodeType.InsufficientFunds, log:"Insufficient fees"}); return false;