}
resOutID := orig.ResultIds[0]
- resOut, ok := orig.Entries[*resOutID].(*bc.IntraChainOutput)
- if ok {
+ switch resOut := orig.Entries[*resOutID].(type) {
+ case *bc.IntraChainOutput:
tx.MuxID = *resOut.Source.Ref
- } else {
+ case *bc.CrossChainOutput:
+ tx.MuxID = *resOut.Source.Ref
+ case *bc.VoteOutput:
+ tx.MuxID = *resOut.Source.Ref
+ case *bc.Retirement:
resRetire, _ := orig.Entries[*resOutID].(*bc.Retirement)
tx.MuxID = *resRetire.Source.Ref
}
switch out := resOut.(type) {
case *bc.IntraChainOutput:
tx.MuxID = *out.Source.Ref
+ case *bc.VoteOutput:
+ tx.MuxID = *out.Source.Ref
case *bc.Retirement:
tx.MuxID = *out.Source.Ref
}
return errors.Wrap(ErrWrongCoinbaseTransaction, "have more than 1 output")
}
- output, err := tx.IntraChainOutput(*tx.TxHeader.ResultIds[0])
- if err != nil {
- return err
+ var SourceAmount uint64
+ switch output := tx.Entries[*tx.TxHeader.ResultIds[0]].(type) {
+ case *bc.IntraChainOutput:
+ SourceAmount = output.Source.Value.Amount
+ case *bc.VoteOutput:
+ SourceAmount = output.Source.Value.Amount
+ default:
+ return errors.Wrapf(bc.ErrEntryType, "entry %x has unexpected type %T", tx.TxHeader.ResultIds[0].Bytes(), output)
}
- if output.Source.Value.Amount != amount {
+ if SourceAmount != amount {
return errors.Wrap(ErrWrongCoinbaseTransaction, "dismatch output amount")
}
return nil
)
switch e := entry.(type) {
-
case *bc.Spend:
- spentOutput := tx.Entries[*e.SpentOutputId].(*bc.IntraChainOutput)
- a1 := spentOutput.Source.Value.AssetId.Bytes()
- assetID = &a1
- amount = &spentOutput.Source.Value.Amount
- destPos = &e.WitnessDestination.Position
- s := e.SpentOutputId.Bytes()
- spentOutputID = &s
+ switch spentOutput := tx.Entries[*e.SpentOutputId].(type) {
+ case *bc.IntraChainOutput:
+ a1 := spentOutput.Source.Value.AssetId.Bytes()
+ assetID = &a1
+ amount = &spentOutput.Source.Value.Amount
+ destPos = &e.WitnessDestination.Position
+ s := e.SpentOutputId.Bytes()
+ spentOutputID = &s
+ case *bc.VoteOutput:
+ a1 := spentOutput.Source.Value.AssetId.Bytes()
+ assetID = &a1
+ amount = &spentOutput.Source.Value.Amount
+ destPos = &e.WitnessDestination.Position
+ s := e.SpentOutputId.Bytes()
+ spentOutputID = &s
+ }
}
var txSigHash *[]byte
case *bc.IntraChainOutput:
return check(e.ControlProgram, e.Source.Value), nil
+ case *bc.VoteOutput:
+ return check(e.ControlProgram, e.Source.Value), nil
+
case *bc.Retirement:
var prog bc.Program
if expansion {
for txIndex := len(b.Transactions) - 1; txIndex >= 0; txIndex-- {
tx := b.Transactions[txIndex]
for j := range tx.Outputs {
- resOut, err := tx.IntraChainOutput(*tx.ResultIds[j])
- if err != nil {
+ code := []byte{}
+ switch resOut := tx.Entries[*tx.ResultIds[j]].(type) {
+ case *bc.IntraChainOutput:
+ code = resOut.ControlProgram.Code
+ case *bc.VoteOutput:
+ code = resOut.ControlProgram.Code
+ default:
continue
}
- if segwit.IsP2WScript(resOut.ControlProgram.Code) {
+ if segwit.IsP2WScript(code) {
batch.Delete(account.StandardUTXOKey(*tx.ResultIds[j]))
} else {
batch.Delete(account.ContractUTXOKey(*tx.ResultIds[j]))