|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package utils
-
- import (
- "fmt"
-
- "github.com/imosed/signet/client"
- "github.com/rs/zerolog/log"
- "github.com/stellar/go/clients/horizonclient"
- "github.com/stellar/go/keypair"
- "github.com/stellar/go/network"
- "github.com/stellar/go/protocols/horizon"
- "github.com/stellar/go/txnbuild"
- )
-
- func SendAsset(from *keypair.Full, memo txnbuild.Memo, operations []txnbuild.Operation) (bool, error) {
- var err error
-
- source := keypair.MustParseFull(from.Seed())
- sourceReq := horizonclient.AccountRequest{AccountID: source.Address()}
- var sourceAcct horizon.Account
- sourceAcct, err = client.SignetClient.AccountDetail(sourceReq)
- if err != nil {
- return false, err
- }
-
- tx, err := txnbuild.NewTransaction(
- txnbuild.TransactionParams{
- SourceAccount: &sourceAcct,
- IncrementSequenceNum: true,
- Operations: operations,
- BaseFee: txnbuild.MinBaseFee,
- Memo: memo,
- Preconditions: txnbuild.Preconditions{
- TimeBounds: txnbuild.NewTimeout(15),
- },
- })
- if err != nil {
-
- return false, err
- }
-
- tx, err = tx.Sign(network.TestNetworkPassphrase, source)
- if err != nil {
- return false, err
- }
-
- var response horizon.Transaction
- response, err = client.SignetClient.SubmitTransaction(tx)
- if err != nil {
- return false, err
- }
-
- log.Info().Msg(fmt.Sprintf("Successful Transaction: { Ledger: %d, Hash: %s }", response.Ledger, response.Hash))
-
- return true, nil
- }
|