Stop passing of missing address in eth tx to bchain.Tx
This commit is contained in:
parent
7419003372
commit
090bb8e4f1
@ -11,7 +11,7 @@ type EthParser struct {
|
|||||||
|
|
||||||
func (p *EthParser) GetAddrIDFromVout(output *bchain.Vout) ([]byte, error) {
|
func (p *EthParser) GetAddrIDFromVout(output *bchain.Vout) ([]byte, error) {
|
||||||
if len(output.ScriptPubKey.Addresses) != 1 {
|
if len(output.ScriptPubKey.Addresses) != 1 {
|
||||||
return nil, nil
|
return nil, bchain.ErrAddressMissing
|
||||||
}
|
}
|
||||||
return p.GetAddrIDFromAddress(output.ScriptPubKey.Addresses[0])
|
return p.GetAddrIDFromAddress(output.ScriptPubKey.Addresses[0])
|
||||||
}
|
}
|
||||||
|
|||||||
@ -273,16 +273,12 @@ func ethNumber(n string) (int64, error) {
|
|||||||
|
|
||||||
func ethTxToTx(tx *rpcTransaction, blocktime int64, confirmations uint32) (*bchain.Tx, error) {
|
func ethTxToTx(tx *rpcTransaction, blocktime int64, confirmations uint32) (*bchain.Tx, error) {
|
||||||
txid := ethHashToHash(tx.Hash)
|
txid := ethHashToHash(tx.Hash)
|
||||||
n, err := ethNumber(tx.TransactionIndex)
|
var fa, ta []string
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
var from, to string
|
|
||||||
if len(tx.To) > 2 {
|
|
||||||
to = tx.To[2:]
|
|
||||||
}
|
|
||||||
if len(tx.From) > 2 {
|
if len(tx.From) > 2 {
|
||||||
from = tx.From[2:]
|
fa = []string{tx.From[2:]}
|
||||||
|
}
|
||||||
|
if len(tx.To) > 2 {
|
||||||
|
ta = []string{tx.To[2:]}
|
||||||
}
|
}
|
||||||
b, err := json.Marshal(tx)
|
b, err := json.Marshal(tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -298,7 +294,7 @@ func ethTxToTx(tx *rpcTransaction, blocktime int64, confirmations uint32) (*bcha
|
|||||||
Txid: txid,
|
Txid: txid,
|
||||||
Vin: []bchain.Vin{
|
Vin: []bchain.Vin{
|
||||||
{
|
{
|
||||||
Addresses: []string{from},
|
Addresses: fa,
|
||||||
// Coinbase
|
// Coinbase
|
||||||
// ScriptSig
|
// ScriptSig
|
||||||
// Sequence
|
// Sequence
|
||||||
@ -308,11 +304,11 @@ func ethTxToTx(tx *rpcTransaction, blocktime int64, confirmations uint32) (*bcha
|
|||||||
},
|
},
|
||||||
Vout: []bchain.Vout{
|
Vout: []bchain.Vout{
|
||||||
{
|
{
|
||||||
N: uint32(n),
|
N: 0, // there is always up to one To address
|
||||||
// Value - cannot set, it does not fit precisely to float64
|
// Value - cannot set, it does not fit precisely to float64
|
||||||
ScriptPubKey: bchain.ScriptPubKey{
|
ScriptPubKey: bchain.ScriptPubKey{
|
||||||
// Hex
|
// Hex
|
||||||
Addresses: []string{to},
|
Addresses: ta,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user