Beispiel #1
0
// MutateSetOptions for ClearFlag sets the SetOptionsOp's ClearFlags field
func (m ClearFlag) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
	if !isFlagValid(xdr.AccountFlags(m)) {
		return errors.New("Unknown flag in SetFlag mutator")
	}

	var val xdr.Uint32
	if o.ClearFlags == nil {
		val = xdr.Uint32(m)
	} else {
		val = xdr.Uint32(m) | *o.ClearFlags
	}
	o.ClearFlags = &val
	return
}
Beispiel #2
0
// MutateSetOptions for Signer sets the SetOptionsOp's signer field
func (m Signer) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
	var signer xdr.Signer
	signer.Weight = xdr.Uint32(m.Weight)
	err = setAccountId(m.PublicKey, &signer.PubKey)
	o.Signer = &signer
	return
}
Beispiel #3
0
// MutateSetOptions for Thresholds sets the SetOptionsOp's thresholds fields
func (m Thresholds) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
	if m.Low != nil {
		val := xdr.Uint32(*m.Low)
		o.LowThreshold = &val
	}

	if m.Medium != nil {
		val := xdr.Uint32(*m.Medium)
		o.MedThreshold = &val
	}

	if m.High != nil {
		val := xdr.Uint32(*m.High)
		o.HighThreshold = &val
	}

	return
}
Beispiel #4
0
// MutateTransaction for Defaults sets reasonable defaults on the transaction being built
func (m Defaults) MutateTransaction(o *TransactionBuilder) error {

	if o.TX.Fee == 0 {
		o.TX.Fee = xdr.Uint32(100 * len(o.TX.Operations))
	}

	if o.NetworkPassphrase == "" {
		o.NetworkPassphrase = DefaultNetwork.Passphrase
	}
	return nil
}
		})
	})

	Describe("Signer", func() {
		Context("using a valid stellar address", func() {
			BeforeEach(func() { mut = Signer{address, 5} })

			It("succeeds", func() {
				Expect(subject.Err).NotTo(HaveOccurred())
			})

			It("sets the values", func() {
				var aid xdr.AccountId
				aid.SetAddress(address)
				Expect(subject.SO.Signer.PubKey.MustEd25519()).To(Equal(aid.MustEd25519()))
				Expect(subject.SO.Signer.Weight).To(Equal(xdr.Uint32(5)))
			})
		})

		Context("using an invalid PubKey", func() {
			BeforeEach(func() { mut = Signer{bad, 5} })
			It("failed", func() { Expect(subject.Err).To(HaveOccurred()) })
		})
	})

	Describe("HomeDomain", func() {
		Context("using a valid value", func() {
			BeforeEach(func() { mut = HomeDomain("stellar.org") })

			It("succeeds", func() {
				Expect(subject.Err).NotTo(HaveOccurred())
Beispiel #6
0
// MutateSetOptions for MasterWeight sets the SetOptionsOp's MasterWeight field
func (m MasterWeight) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
	val := xdr.Uint32(m)
	o.MasterWeight = &val
	return
}