diff --git a/build/main.go b/build/main.go index f4942cb7b7..498272e27f 100644 --- a/build/main.go +++ b/build/main.go @@ -217,6 +217,11 @@ type Thresholds struct { High *uint32 } +type Timebounds struct { + MinTime uint64 + MaxTime uint64 +} + // Trustor is a mutator capable of setting the trustor on // allow_trust operation. type Trustor struct { diff --git a/build/transaction.go b/build/transaction.go index b175c01e70..538a897670 100644 --- a/build/transaction.go +++ b/build/transaction.go @@ -256,6 +256,11 @@ func (m MemoText) MutateTransaction(o *TransactionBuilder) (err error) { return } +func (m Timebounds) MutateTransaction(o *TransactionBuilder) error { + o.TX.TimeBounds = &xdr.TimeBounds{MinTime: xdr.Uint64(m.MinTime), MaxTime: xdr.Uint64(m.MaxTime)} + return nil +} + // MutateTransaction for Network sets the Network ID to use when signing this transaction func (m Network) MutateTransaction(o *TransactionBuilder) error { o.NetworkPassphrase = m.Passphrase diff --git a/build/transaction_test.go b/build/transaction_test.go index 22c50dd78c..144f3c4e8c 100644 --- a/build/transaction_test.go +++ b/build/transaction_test.go @@ -111,6 +111,15 @@ var _ = Describe("Transaction Mutators:", func() { }) }) + Describe("Timebounds", func() { + BeforeEach(func() { mut = Timebounds{1521056118, 1521056298} }) + It("succeeds", func() { Expect(err).NotTo(HaveOccurred()) }) + It("sets an minimum and maximum timebound on the transaction", func() { + Expect(subject.TX.TimeBounds.MinTime).To(Equal(xdr.Uint64(1521056118))) + Expect(subject.TX.TimeBounds.MaxTime).To(Equal(xdr.Uint64(1521056298))) + }) + }) + Describe("AllowTrustBuilder", func() { BeforeEach(func() { mut = AllowTrust() }) It("adds itself to the tx's operations", func() {