Search in sources :

Example 1 with TransferInvoke

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);
}
Also used : ProgramSubtrace(co.rsk.rpc.modules.trace.ProgramSubtrace) ProgramResult(org.ethereum.vm.program.ProgramResult) DataWord(org.ethereum.vm.DataWord) TransferInvoke(org.ethereum.vm.program.invoke.TransferInvoke)

Example 2 with TransferInvoke

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());
    }
}
Also used : SummarizedProgramTrace(org.ethereum.vm.trace.SummarizedProgramTrace) ProgramTrace(org.ethereum.vm.trace.ProgramTrace) ProgramSubtrace(co.rsk.rpc.modules.trace.ProgramSubtrace) TransferInvoke(org.ethereum.vm.program.invoke.TransferInvoke) SummarizedProgramTrace(org.ethereum.vm.trace.SummarizedProgramTrace)

Example 3 with TransferInvoke

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);
}
Also used : ProgramSubtrace(co.rsk.rpc.modules.trace.ProgramSubtrace) ProgramResult(org.ethereum.vm.program.ProgramResult) DataWord(org.ethereum.vm.DataWord) TransferInvoke(org.ethereum.vm.program.invoke.TransferInvoke)

Aggregations

ProgramSubtrace (co.rsk.rpc.modules.trace.ProgramSubtrace)3 TransferInvoke (org.ethereum.vm.program.invoke.TransferInvoke)3 DataWord (org.ethereum.vm.DataWord)2 ProgramResult (org.ethereum.vm.program.ProgramResult)2 ProgramTrace (org.ethereum.vm.trace.ProgramTrace)1 SummarizedProgramTrace (org.ethereum.vm.trace.SummarizedProgramTrace)1