pull/541/head
sidhujag 2020-09-06 15:14:24 -07:00
parent eba5b07f03
commit dea6a14c67
4 changed files with 17 additions and 2 deletions

View File

@ -257,7 +257,7 @@ func (w *Worker) GetTransactionFromBchainTx(bchainTx *bchain.Tx, height int, spe
vout.N = i
vout.ValueSat = (*bchain.Amount)(&bchainVout.ValueSat)
valOutSat.Add(&valOutSat, &bchainVout.ValueSat)
vout.AssetInfo = bchainVin.AssetInfo
vout.AssetInfo = bchainVout.AssetInfo
if vout.AssetInfo != nil {
if mapTTS == nil {
mapTTS = map[uint32]*bchain.TokenTransferSummary{}

View File

@ -359,6 +359,9 @@ func (p *BaseParser) UnpackAssetTxIndex(buf []byte) []*TxAssetIndex {
func (p *BaseParser) GetAssetFromData(sptData []byte) (*Asset, error) {
return nil, errors.New("Not supported")
}
func (p *BaseParser) GetAssetAllocationFromData(sptData []byte) (*AssetAllocation, error) {
return nil, errors.New("Not supported")
}
func (p *BaseParser) GetAssetFromDesc(addrDesc *AddressDescriptor) (*Asset, error) {
return nil, errors.New("Not supported")
}

View File

@ -264,7 +264,7 @@ func (p *SyscoinParser) GetAllocationFromTx(tx *bchain.Tx) (*bchain.AssetAllocat
break
}
}
return p.GetAssetFromDesc(&addrDesc)
return p.GetAssetAllocationFromData(sptData)
}
func (p *SyscoinParser) GetAssetFromDesc(addrDesc *bchain.AddressDescriptor) (*bchain.Asset, error) {
@ -288,6 +288,15 @@ func (p *SyscoinParser) GetAssetFromData(sptData []byte) (*bchain.Asset, error)
}
return &asset, nil
}
func (p *SyscoinParser) GetAssetAllocationFromData(sptData []byte) (*bchain.AssetAllocation, error) {
var assetAllocation bchain.AssetAllocation
r := bytes.NewReader(sptData)
err := assetAllocation.AssetObj.Deserialize(r)
if err != nil {
return nil, err
}
return &assetAllocation, nil
}
func (p *SyscoinParser) LoadAssets(tx *bchain.Tx) error {
if p.IsSyscoinTx(tx.Version) {
allocation, err := p.GetAllocationFromTx(tx);

View File

@ -66,6 +66,7 @@ type Vin struct {
ScriptSig ScriptSig `json:"scriptSig"`
Sequence uint32 `json:"sequence"`
Addresses []string `json:"addresses"`
AssetInfo *AssetInfo `json:"assetInfo,omitempty"`
}
// ScriptPubKey contains data about output script
@ -107,6 +108,7 @@ type MempoolVin struct {
Vin
AddrDesc AddressDescriptor `json:"-"`
ValueSat big.Int
AssetInfo *AssetInfo `json:"assetInfo,omitempty"`
}
// MempoolTx is blockchain transaction in mempool
@ -760,6 +762,7 @@ type BlockChainParser interface {
PackAsset(asset *Asset) ([]byte, error)
UnpackAsset(buf []byte) (*Asset, error)
GetAssetFromData(sptData []byte) (*Asset, error)
GetAssetAllocationFromData(sptData []byte) (*AssetAllocation, error)
GetAssetFromDesc(addrDesc *AddressDescriptor) (*Asset, error)
GetAllocationFromTx(tx *Tx) (*AssetAllocation, error)
LoadAssets(tx *Tx) error