use of org.ethereum.vm.program.invoke.TransferInvoke in project rskj by rsksmart.
the class RemascFeesPayer method transferPayment.
private void transferPayment(Coin value, RskAddress toAddress) {
this.repository.addBalance(contractAddress, value.negate());
this.repository.addBalance(toAddress, value);
DataWord from = DataWord.valueOf(contractAddress.getBytes());
DataWord to = DataWord.valueOf(toAddress.getBytes());
long gas = 0L;
DataWord amount = DataWord.valueOf(value.getBytes());
TransferInvoke invoke = new TransferInvoke(from, to, gas, amount);
ProgramResult result = new ProgramResult();
ProgramSubtrace subtrace = ProgramSubtrace.newCallSubtrace(CallType.CALL, invoke, result, null, Collections.emptyList());
this.subtraces.add(subtrace);
}
use of org.ethereum.vm.program.invoke.TransferInvoke in project rskj by rsksmart.
the class TransactionExecutor method extractTrace.
/**
* This extracts the trace to an object in memory.
* Refer to {@link org.ethereum.vm.VMUtils#saveProgramTraceFile} for a way to saving the trace to a file.
*/
public void extractTrace(ProgramTraceProcessor programTraceProcessor) {
if (program != null) {
// TODO improve this settings; the trace should already have the values
ProgramTrace trace = program.getTrace().result(result.getHReturn()).error(result.getException()).revert(result.isRevert());
programTraceProcessor.processProgramTrace(trace, tx.getHash());
} else {
TransferInvoke invoke = new TransferInvoke(DataWord.valueOf(tx.getSender().getBytes()), DataWord.valueOf(tx.getReceiveAddress().getBytes()), 0L, DataWord.valueOf(tx.getValue().getBytes()));
SummarizedProgramTrace trace = new SummarizedProgramTrace(invoke);
if (this.subtraces != null) {
for (ProgramSubtrace subtrace : this.subtraces) {
trace.addSubTrace(subtrace);
}
}
programTraceProcessor.processProgramTrace(trace, tx.getHash());
}
}
use of org.ethereum.vm.program.invoke.TransferInvoke in project rskj by rsksmart.
the class BridgeSupport method transferTo.
/**
* Internal method to transfer RSK to an RSK account
* It also produce the appropiate internal transaction subtrace if needed
*
* @param receiver address that receives the amount
* @param amount amount to transfer
*/
private void transferTo(RskAddress receiver, co.rsk.core.Coin amount) {
rskRepository.transfer(PrecompiledContracts.BRIDGE_ADDR, receiver, amount);
DataWord from = DataWord.valueOf(PrecompiledContracts.BRIDGE_ADDR.getBytes());
DataWord to = DataWord.valueOf(receiver.getBytes());
long gas = 0L;
DataWord value = DataWord.valueOf(amount.getBytes());
TransferInvoke invoke = new TransferInvoke(from, to, gas, value);
ProgramResult result = ProgramResult.empty();
ProgramSubtrace subtrace = ProgramSubtrace.newCallSubtrace(CallType.CALL, invoke, result, null, Collections.emptyList());
logger.info("Transferred {} weis to {}", amount, receiver);
this.subtraces.add(subtrace);
}
Aggregations