コード例 #1
0
ファイル: set_options.go プロジェクト: FihlaTV/bridge-server
// 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
}
コード例 #2
0
ファイル: set_options.go プロジェクト: FihlaTV/bridge-server
// 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
}
コード例 #3
0
ファイル: set_options.go プロジェクト: FihlaTV/bridge-server
// 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
}
コード例 #4
0
ファイル: transaction.go プロジェクト: FihlaTV/bridge-server
// 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.NetworkID == [32]byte{} {
		o.NetworkID = DefaultNetwork.ID()
	}
	return nil
}
コード例 #5
0
ファイル: set_options.go プロジェクト: FihlaTV/bridge-server
// 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
}
コード例 #6
0
			It("failed", func() { Expect(subject.Err).To(HaveOccurred()) })
		})
	})

	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() {
				aid, _ := stellarbase.AddressToAccountId(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())