OSDN Git Service

Merge pull request #201 from Bytom/v0.1
[bytom/vapor.git] / vendor / github.com / bytom / protocol / bc / spend.go
diff --git a/vendor/github.com/bytom/protocol/bc/spend.go b/vendor/github.com/bytom/protocol/bc/spend.go
new file mode 100644 (file)
index 0000000..729c49d
--- /dev/null
@@ -0,0 +1,30 @@
+package bc
+
+import "io"
+
+// Spend accesses the value in a prior Output for transfer
+// elsewhere. It satisfies the Entry interface.
+//
+// (Not to be confused with the deprecated type SpendInput.)
+
+func (Spend) typ() string { return "spend1" }
+func (s *Spend) writeForHash(w io.Writer) {
+       mustWriteForHash(w, s.SpentOutputId)
+}
+
+// SetDestination will link the spend to the output
+func (s *Spend) SetDestination(id *Hash, val *AssetAmount, pos uint64) {
+       s.WitnessDestination = &ValueDestination{
+               Ref:      id,
+               Value:    val,
+               Position: pos,
+       }
+}
+
+// NewSpend creates a new Spend.
+func NewSpend(spentOutputID *Hash, ordinal uint64) *Spend {
+       return &Spend{
+               SpentOutputId: spentOutputID,
+               Ordinal:       ordinal,
+       }
+}