TransactionEncoder.smali
.class public Lorg/web3j/crypto/TransactionEncoder;
.super Ljava/lang/Object;
.source "TransactionEncoder.java"
# direct methods
.method public constructor <init>()V
.registers 1
.prologue
.line 17
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method static asRlpValues(Lorg/web3j/crypto/RawTransaction;Lorg/web3j/crypto/Sign$SignatureData;)Ljava/util/List;
.registers 5
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lorg/web3j/crypto/RawTransaction;",
"Lorg/web3j/crypto/Sign$SignatureData;",
")",
"Ljava/util/List",
"<",
"Lorg/web3j/rlp/RlpType;",
">;"
}
.end annotation
.prologue
.line 63
new-instance v0, Ljava/util/ArrayList;
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
.line 65
invoke-virtual {p0}, Lorg/web3j/crypto/RawTransaction;->getNonce()Ljava/math/BigInteger;
move-result-object v1
invoke-static {v1}, Lorg/web3j/rlp/RlpString;->create(Ljava/math/BigInteger;)Lorg/web3j/rlp/RlpString;
move-result-object v1
invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
.line 66
invoke-virtual {p0}, Lorg/web3j/crypto/RawTransaction;->getGasPrice()Ljava/math/BigInteger;
move-result-object v1
invoke-static {v1}, Lorg/web3j/rlp/RlpString;->create(Ljava/math/BigInteger;)Lorg/web3j/rlp/RlpString;
move-result-object v1
invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
.line 67
invoke-virtual {p0}, Lorg/web3j/crypto/RawTransaction;->getGasLimit()Ljava/math/BigInteger;
move-result-object v1
invoke-static {v1}, Lorg/web3j/rlp/RlpString;->create(Ljava/math/BigInteger;)Lorg/web3j/rlp/RlpString;
move-result-object v1
invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
.line 70
invoke-virtual {p0}, Lorg/web3j/crypto/RawTransaction;->getTo()Ljava/lang/String;
move-result-object v1
.line 71
if-eqz v1, :cond_83
invoke-virtual {v1}, Ljava/lang/String;->length()I
move-result v2
if-lez v2, :cond_83
.line 74
invoke-static {v1}, Lorg/web3j/utils/Numeric;->hexStringToByteArray(Ljava/lang/String;)[B
move-result-object v1
invoke-static {v1}, Lorg/web3j/rlp/RlpString;->create([B)Lorg/web3j/rlp/RlpString;
move-result-object v1
invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
.line 79
:goto_3d
invoke-virtual {p0}, Lorg/web3j/crypto/RawTransaction;->getValue()Ljava/math/BigInteger;
move-result-object v1
invoke-static {v1}, Lorg/web3j/rlp/RlpString;->create(Ljava/math/BigInteger;)Lorg/web3j/rlp/RlpString;
move-result-object v1
invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
.line 82
invoke-virtual {p0}, Lorg/web3j/crypto/RawTransaction;->getData()Ljava/lang/String;
move-result-object v1
invoke-static {v1}, Lorg/web3j/utils/Numeric;->hexStringToByteArray(Ljava/lang/String;)[B
move-result-object v1
.line 83
invoke-static {v1}, Lorg/web3j/rlp/RlpString;->create([B)Lorg/web3j/rlp/RlpString;
move-result-object v1
invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
.line 85
if-eqz p1, :cond_82
.line 86
invoke-virtual {p1}, Lorg/web3j/crypto/Sign$SignatureData;->getV()B
move-result v1
invoke-static {v1}, Lorg/web3j/rlp/RlpString;->create(B)Lorg/web3j/rlp/RlpString;
move-result-object v1
invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
.line 87
invoke-virtual {p1}, Lorg/web3j/crypto/Sign$SignatureData;->getR()[B
move-result-object v1
invoke-static {v1}, Lorg/web3j/utils/Bytes;->trimLeadingZeroes([B)[B
move-result-object v1
invoke-static {v1}, Lorg/web3j/rlp/RlpString;->create([B)Lorg/web3j/rlp/RlpString;
move-result-object v1
invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
.line 88
invoke-virtual {p1}, Lorg/web3j/crypto/Sign$SignatureData;->getS()[B
move-result-object v1
invoke-static {v1}, Lorg/web3j/utils/Bytes;->trimLeadingZeroes([B)[B
move-result-object v1
invoke-static {v1}, Lorg/web3j/rlp/RlpString;->create([B)Lorg/web3j/rlp/RlpString;
move-result-object v1
invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
.line 91
:cond_82
return-object v0
.line 76
:cond_83
const-string v1, ""
invoke-static {v1}, Lorg/web3j/rlp/RlpString;->create(Ljava/lang/String;)Lorg/web3j/rlp/RlpString;
move-result-object v1
invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
goto :goto_3d
.end method
.method public static createEip155SignatureData(Lorg/web3j/crypto/Sign$SignatureData;B)Lorg/web3j/crypto/Sign$SignatureData;
.registers 6
.prologue
.line 39
invoke-virtual {p0}, Lorg/web3j/crypto/Sign$SignatureData;->getV()B
move-result v0
shl-int/lit8 v1, p1, 0x1
add-int/2addr v0, v1
add-int/lit8 v0, v0, 0x8
int-to-byte v0, v0
.line 41
new-instance v1, Lorg/web3j/crypto/Sign$SignatureData;
invoke-virtual {p0}, Lorg/web3j/crypto/Sign$SignatureData;->getR()[B
move-result-object v2
invoke-virtual {p0}, Lorg/web3j/crypto/Sign$SignatureData;->getS()[B
move-result-object v3
invoke-direct {v1, v0, v2, v3}, Lorg/web3j/crypto/Sign$SignatureData;-><init>(B[B[B)V
return-object v1
.end method
.method public static encode(Lorg/web3j/crypto/RawTransaction;)[B
.registers 2
.prologue
.line 46
const/4 v0, 0x0
invoke-static {p0, v0}, Lorg/web3j/crypto/TransactionEncoder;->encode(Lorg/web3j/crypto/RawTransaction;Lorg/web3j/crypto/Sign$SignatureData;)[B
move-result-object v0
return-object v0
.end method
.method public static encode(Lorg/web3j/crypto/RawTransaction;B)[B
.registers 5
.prologue
const/4 v2, 0x0
.line 50
new-instance v0, Lorg/web3j/crypto/Sign$SignatureData;
new-array v1, v2, [B
new-array v2, v2, [B
invoke-direct {v0, p1, v1, v2}, Lorg/web3j/crypto/Sign$SignatureData;-><init>(B[B[B)V
.line 52
invoke-static {p0, v0}, Lorg/web3j/crypto/TransactionEncoder;->encode(Lorg/web3j/crypto/RawTransaction;Lorg/web3j/crypto/Sign$SignatureData;)[B
move-result-object v0
return-object v0
.end method
.method private static encode(Lorg/web3j/crypto/RawTransaction;Lorg/web3j/crypto/Sign$SignatureData;)[B
.registers 4
.prologue
.line 56
invoke-static {p0, p1}, Lorg/web3j/crypto/TransactionEncoder;->asRlpValues(Lorg/web3j/crypto/RawTransaction;Lorg/web3j/crypto/Sign$SignatureData;)Ljava/util/List;
move-result-object v0
.line 57
new-instance v1, Lorg/web3j/rlp/RlpList;
invoke-direct {v1, v0}, Lorg/web3j/rlp/RlpList;-><init>(Ljava/util/List;)V
.line 58
invoke-static {v1}, Lorg/web3j/rlp/RlpEncoder;->encode(Lorg/web3j/rlp/RlpType;)[B
move-result-object v0
return-object v0
.end method
.method public static signMessage(Lorg/web3j/crypto/RawTransaction;BLorg/web3j/crypto/Credentials;)[B
.registers 5
.prologue
.line 29
invoke-static {p0, p1}, Lorg/web3j/crypto/TransactionEncoder;->encode(Lorg/web3j/crypto/RawTransaction;B)[B
move-result-object v0
.line 30
invoke-virtual {p2}, Lorg/web3j/crypto/Credentials;->getEcKeyPair()Lorg/web3j/crypto/ECKeyPair;
move-result-object v1
invoke-static {v0, v1}, Lorg/web3j/crypto/Sign;->signMessage([BLorg/web3j/crypto/ECKeyPair;)Lorg/web3j/crypto/Sign$SignatureData;
move-result-object v0
.line 33
invoke-static {v0, p1}, Lorg/web3j/crypto/TransactionEncoder;->createEip155SignatureData(Lorg/web3j/crypto/Sign$SignatureData;B)Lorg/web3j/crypto/Sign$SignatureData;
move-result-object v0
.line 34
invoke-static {p0, v0}, Lorg/web3j/crypto/TransactionEncoder;->encode(Lorg/web3j/crypto/RawTransaction;Lorg/web3j/crypto/Sign$SignatureData;)[B
move-result-object v0
return-object v0
.end method
.method public static signMessage(Lorg/web3j/crypto/RawTransaction;Lorg/web3j/crypto/Credentials;)[B
.registers 4
.prologue
.line 20
invoke-static {p0}, Lorg/web3j/crypto/TransactionEncoder;->encode(Lorg/web3j/crypto/RawTransaction;)[B
move-result-object v0
.line 21
invoke-virtual {p1}, Lorg/web3j/crypto/Credentials;->getEcKeyPair()Lorg/web3j/crypto/ECKeyPair;
move-result-object v1
invoke-static {v0, v1}, Lorg/web3j/crypto/Sign;->signMessage([BLorg/web3j/crypto/ECKeyPair;)Lorg/web3j/crypto/Sign$SignatureData;
move-result-object v0
.line 24
invoke-static {p0, v0}, Lorg/web3j/crypto/TransactionEncoder;->encode(Lorg/web3j/crypto/RawTransaction;Lorg/web3j/crypto/Sign$SignatureData;)[B
move-result-object v0
return-object v0
.end method