Send an asset from one account to another
(scid crypto.Hash, ringsize uint64, address string, amount string)
| 3062 | |
| 3063 | // Send an asset from one account to another |
| 3064 | func transferAsset(scid crypto.Hash, ringsize uint64, address string, amount string) (txid crypto.Hash, err error) { |
| 3065 | var amount_to_transfer uint64 |
| 3066 | |
| 3067 | if amount == "" { |
| 3068 | amount = ".00001" |
| 3069 | } |
| 3070 | |
| 3071 | amount_to_transfer, err = globals.ParseAmount(amount) |
| 3072 | if err != nil { |
| 3073 | logger.Errorf("[Transfer] Failed parsing transfer amount: %s\n", err) |
| 3074 | return |
| 3075 | } |
| 3076 | |
| 3077 | tx, err := engram.Disk.TransferPayload0([]rpc.Transfer{{SCID: scid, Amount: amount_to_transfer, Destination: address}}, ringsize, false, rpc.Arguments{}, 0, false) |
| 3078 | if err != nil { |
| 3079 | logger.Errorf("[Transfer] Failed to build transaction: %s\n", err) |
| 3080 | return |
| 3081 | } |
| 3082 | |
| 3083 | if err = engram.Disk.SendTransaction(tx); err != nil { |
| 3084 | logger.Errorf("[Transfer] Failed to send asset: %s - %s\n", scid, err) |
| 3085 | return |
| 3086 | } |
| 3087 | |
| 3088 | txid = tx.GetHash() |
| 3089 | |
| 3090 | logger.Printf("[Transfer] Successfully sent asset: %s - TXID: %s\n", scid, tx.GetHash().String()) |
| 3091 | return |
| 3092 | } |
| 3093 | |
| 3094 | // Transfer a username to another account |
| 3095 | func transferUsername(username string, address string) (storage uint64, err error) { |
no outgoing calls
no test coverage detected