Return ethereum address including the standard 0x prefix

This commit is contained in:
Martin Boehm 2018-04-07 23:44:38 +02:00
parent f8eca976ab
commit 8a8952d103
3 changed files with 13 additions and 13 deletions

View File

@ -54,10 +54,10 @@ func ethTxToTx(tx *rpcTransaction, blocktime int64, confirmations uint32) (*bcha
txid := ethHashToHash(tx.Hash) txid := ethHashToHash(tx.Hash)
var fa, ta []string var fa, ta []string
if len(tx.From) > 2 { if len(tx.From) > 2 {
fa = []string{tx.From[2:]} fa = []string{tx.From}
} }
if len(tx.To) > 2 { if len(tx.To) > 2 {
ta = []string{tx.To[2:]} ta = []string{tx.To}
} }
// temporarily, the complete rpcTransaction without BlockHash is marshalled and hex encoded to bchain.Tx.Hex // temporarily, the complete rpcTransaction without BlockHash is marshalled and hex encoded to bchain.Tx.Hex
bh := tx.BlockHash bh := tx.BlockHash

View File

@ -165,13 +165,13 @@ func TestEthereumParser_UnpackTx(t *testing.T) {
Txid: "e6b168d6bb3d8ed78e03dbf828b6bfd1fb613f6e129cba624964984553724c5d", Txid: "e6b168d6bb3d8ed78e03dbf828b6bfd1fb613f6e129cba624964984553724c5d",
Vin: []bchain.Vin{ Vin: []bchain.Vin{
{ {
Addresses: []string{"dacc9c61754a0c4616fc5323dc946e89eb272302"}, Addresses: []string{"0xdacc9c61754a0c4616fc5323dc946e89eb272302"},
}, },
}, },
Vout: []bchain.Vout{ Vout: []bchain.Vout{
{ {
ScriptPubKey: bchain.ScriptPubKey{ ScriptPubKey: bchain.ScriptPubKey{
Addresses: []string{"682b7903a11098cf770c7aef4aa02a85b3f3601a"}, Addresses: []string{"0x682b7903a11098cf770c7aef4aa02a85b3f3601a"},
}, },
}, },
}, },
@ -188,13 +188,13 @@ func TestEthereumParser_UnpackTx(t *testing.T) {
Txid: "cd647151552b5132b2aef7c9be00dc6f73afc5901dde157aab131335baaa853b", Txid: "cd647151552b5132b2aef7c9be00dc6f73afc5901dde157aab131335baaa853b",
Vin: []bchain.Vin{ Vin: []bchain.Vin{
{ {
Addresses: []string{"3e3a3d69dc66ba10737f531ed088954a9ec89d97"}, Addresses: []string{"0x3e3a3d69dc66ba10737f531ed088954a9ec89d97"},
}, },
}, },
Vout: []bchain.Vout{ Vout: []bchain.Vout{
{ {
ScriptPubKey: bchain.ScriptPubKey{ ScriptPubKey: bchain.ScriptPubKey{
Addresses: []string{"555ee11fbddc0e49a9bab358a8941ad95ffdb48f"}, Addresses: []string{"0x555ee11fbddc0e49a9bab358a8941ad95ffdb48f"},
}, },
}, },
}, },

View File

@ -225,7 +225,7 @@ func TestEthRPC_GetBlockHeader(t *testing.T) {
b: setupEthRPC(), b: setupEthRPC(),
}, },
args: args{ args: args{
hash: "eccd6b0031015a19cb7d4e10f28590ba65a6a54ad1baa322b50fe5ad16903896", hash: "0xeccd6b0031015a19cb7d4e10f28590ba65a6a54ad1baa322b50fe5ad16903896",
}, },
wantErr: bchain.ErrBlockNotFound, wantErr: bchain.ErrBlockNotFound,
}, },
@ -304,7 +304,7 @@ func TestEthRPC_GetBlock(t *testing.T) {
b: setupEthRPC(), b: setupEthRPC(),
}, },
args: args{ args: args{
hash: "eccd6b0031015a19cb7d4e10f28590ba65a6a54ad1baa322b50fe5ad16903896", hash: "0xeccd6b0031015a19cb7d4e10f28590ba65a6a54ad1baa322b50fe5ad16903896",
}, },
wantErr: bchain.ErrBlockNotFound, wantErr: bchain.ErrBlockNotFound,
}, },
@ -363,7 +363,7 @@ func TestEthRPC_GetTransaction(t *testing.T) {
b: setupEthRPC(), b: setupEthRPC(),
}, },
args: args{ args: args{
txid: "e6b168d6bb3d8ed78e03dbf828b6bfd1fb613f6e129cba624964984553724c5d", txid: "0xe6b168d6bb3d8ed78e03dbf828b6bfd1fb613f6e129cba624964984553724c5d",
}, },
want: &bchain.Tx{ want: &bchain.Tx{
Blocktime: 1521515026, Blocktime: 1521515026,
@ -373,13 +373,13 @@ func TestEthRPC_GetTransaction(t *testing.T) {
Txid: "e6b168d6bb3d8ed78e03dbf828b6bfd1fb613f6e129cba624964984553724c5d", Txid: "e6b168d6bb3d8ed78e03dbf828b6bfd1fb613f6e129cba624964984553724c5d",
Vin: []bchain.Vin{ Vin: []bchain.Vin{
{ {
Addresses: []string{"dacc9c61754a0c4616fc5323dc946e89eb272302"}, Addresses: []string{"0xdacc9c61754a0c4616fc5323dc946e89eb272302"},
}, },
}, },
Vout: []bchain.Vout{ Vout: []bchain.Vout{
{ {
ScriptPubKey: bchain.ScriptPubKey{ ScriptPubKey: bchain.ScriptPubKey{
Addresses: []string{"682b7903a11098cf770c7aef4aa02a85b3f3601a"}, Addresses: []string{"0x682b7903a11098cf770c7aef4aa02a85b3f3601a"},
}, },
}, },
}, },
@ -401,13 +401,13 @@ func TestEthRPC_GetTransaction(t *testing.T) {
Txid: "cd647151552b5132b2aef7c9be00dc6f73afc5901dde157aab131335baaa853b", Txid: "cd647151552b5132b2aef7c9be00dc6f73afc5901dde157aab131335baaa853b",
Vin: []bchain.Vin{ Vin: []bchain.Vin{
{ {
Addresses: []string{"3e3a3d69dc66ba10737f531ed088954a9ec89d97"}, Addresses: []string{"0x3e3a3d69dc66ba10737f531ed088954a9ec89d97"},
}, },
}, },
Vout: []bchain.Vout{ Vout: []bchain.Vout{
{ {
ScriptPubKey: bchain.ScriptPubKey{ ScriptPubKey: bchain.ScriptPubKey{
Addresses: []string{"555ee11fbddc0e49a9bab358a8941ad95ffdb48f"}, Addresses: []string{"0x555ee11fbddc0e49a9bab358a8941ad95ffdb48f"},
}, },
}, },
}, },