OSDN Git Service

Small edit (#241)
[bytom/vapor.git] / protocol / bc / types / map.go
index 0fe229d..27f687e 100644 (file)
@@ -55,10 +55,9 @@ func MapTx(oldTx *TxData) *bc.Tx {
                        continue
                }
 
-               if ord >= uint64(len(oldTx.Inputs)) {
-                       continue
+               if ord < uint64(len(oldTx.Inputs)) {
+                       tx.InputIDs[ord] = id
                }
-               tx.InputIDs[ord] = id
        }
 
        for id := range spentOutputIDs {
@@ -149,18 +148,18 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash
                        }
 
                        prevout := bc.NewIntraChainOutput(src, prog, 0) // ordinal doesn't matter
-                       outputID := bc.EntryID(prevout)
+                       mainchainOutputID := addEntry(prevout)
 
                        assetDefHash := bc.NewHash(sha3.Sum256(inp.AssetDefinition))
                        assetDef := &bc.AssetDefinition{
                                Data: &assetDefHash,
                                IssuanceProgram: &bc.Program{
-                                       VmVersion: inp.VMVersion,
+                                       VmVersion: inp.IssuanceVMVersion,
                                        Code:      inp.IssuanceProgram,
                                },
                        }
 
-                       crossIn := bc.NewCrossChainInput(&outputID, &inp.AssetAmount, prog, uint64(i), assetDef)
+                       crossIn := bc.NewCrossChainInput(&mainchainOutputID, prog, uint64(i), assetDef)
                        crossIn.WitnessArguments = inp.Arguments
                        crossInID := addEntry(crossIn)
                        muxSources[i] = &bc.ValueSource{
@@ -186,7 +185,8 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash
        }
 
        for _, crossIn := range crossIns {
-               crossIn.SetDestination(&muxID, crossIn.Value, crossIn.Ordinal)
+               mainchainOutput := entryMap[*crossIn.MainchainOutputId].(*bc.IntraChainOutput)
+               crossIn.SetDestination(&muxID, mainchainOutput.Source.Value, crossIn.Ordinal)
        }
 
        if coinbase != nil {
@@ -224,7 +224,7 @@ func mapTx(tx *TxData) (headerID bc.Hash, hdr *bc.TxHeader, entryMap map[bc.Hash
 
                case out.OutputType() == VoteOutputType:
                        // non-retirement vote tx
-                       voteOut, _ := out.TypedOutput.(*VoteTxOutput)
+                       voteOut, _ := out.TypedOutput.(*VoteOutput)
                        prog := &bc.Program{out.VMVersion(), out.ControlProgram()}
                        o := bc.NewVoteOutput(src, prog, uint64(i), voteOut.Vote)
                        resultID = addEntry(o)