type crossInAction struct {
bc.AssetAmount
- SourceID bc.Hash `json:"source_id"`
- SourcePos uint64 `json:"source_pos"`
- VMVersion uint64 `json:"vm_version"`
- RawDefinitionByte []byte `json:"raw_definition_byte"`
- IssuanceProgram []byte `json:"issuance_program"`
+ SourceID bc.Hash `json:"source_id"`
+ SourcePos uint64 `json:"source_pos"`
+ VMVersion uint64 `json:"vm_version"`
+ RawDefinitionByte json.HexBytes `json:"raw_definition_byte"`
+ IssuanceProgram json.HexBytes `json:"issuance_program"`
}
func (a *crossInAction) Build(ctx context.Context, builder *TemplateBuilder) error {
return err
}
- if len(tx.GasInputIDs) == 0 {
- return ErrNoGasInput
+ if err := checkGasInputIDs(tx); err != nil {
+ return err
}
// This part is use for prevent tx size is 0
fee = totalInputBTM - totalOutputBTM
return
}
+
+func checkGasInputIDs(tx *types.Tx) error {
+ crossChainInputNum := 0
+ for _, inp := range tx.Inputs {
+ switch inp.InputType() {
+ case types.CrossChainInputType:
+ crossChainInputNum++
+ }
+ }
+
+ if crossChainInputNum != len(tx.Inputs) && len(tx.GasInputIDs) == 0 {
+ return ErrNoGasInput
+ }
+ return nil
+}
}
func isTransactionNoBtmInput(tx *types.Tx) bool {
+ crossChainInputNum := 0
for _, input := range tx.TxData.Inputs {
if input.AssetID() == *consensus.BTMAssetID {
return false
}
+ switch input.InputType() {
+ case types.CrossChainInputType:
+ crossChainInputNum++
+ }
+ }
+ if crossChainInputNum == len(tx.TxData.Inputs) {
+ return false
}
return true
}