OSDN Git Service

Merge pull request #201 from Bytom/v0.1
[bytom/vapor.git] / protocol / bc / types / crosschain_output.go
diff --git a/protocol/bc/types/crosschain_output.go b/protocol/bc/types/crosschain_output.go
new file mode 100644 (file)
index 0000000..afc9201
--- /dev/null
@@ -0,0 +1,31 @@
+package types
+
+import (
+       "github.com/vapor/protocol/bc"
+)
+
+// CrossChainOutput satisfies the TypedOutput interface and represents a cross-chain transaction.
+type CrossChainOutput struct {
+       OutputCommitment
+       // Unconsumed suffixes of the commitment and witness extensible strings.
+       CommitmentSuffix []byte
+}
+
+// NewCrossChainOutput create a new output struct
+func NewCrossChainOutput(assetID bc.AssetID, amount uint64, controlProgram []byte) *TxOutput {
+       return &TxOutput{
+               AssetVersion: 1,
+               TypedOutput: &CrossChainOutput{
+                       OutputCommitment: OutputCommitment{
+                               AssetAmount: bc.AssetAmount{
+                                       AssetId: &assetID,
+                                       Amount:  amount,
+                               },
+                               VMVersion:      1,
+                               ControlProgram: controlProgram,
+                       },
+               },
+       }
+}
+
+func (it *CrossChainOutput) OutputType() uint8 { return CrossChainOutputType }