chore(code-samples): remove all emojis

This commit is contained in:
banasa44
2025-08-25 11:27:50 +02:00
parent 22d67e640d
commit 162a97887e
40 changed files with 1125 additions and 1123 deletions

View File

@@ -56,7 +56,7 @@ func main() {
return return
} }
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
if err := client.FundWallet(&userWallet); err != nil { if err := client.FundWallet(&userWallet); err != nil {
fmt.Println(err) fmt.Println(err)
return return
@@ -65,7 +65,7 @@ func main() {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallets funded") fmt.Println("Wallets funded")
// Check initial balances // Check initial balances
userBalance, err := client.GetXrpBalance(userWallet.ClassicAddress) userBalance, err := client.GetXrpBalance(userWallet.ClassicAddress)
@@ -82,9 +82,9 @@ func main() {
receiverBalance = "0" receiverBalance = "0"
} }
fmt.Printf("💳 User initial balance: %s XRP\n", userBalance) fmt.Printf("User initial balance: %s XRP\n", userBalance)
fmt.Printf("💳 User2 initial balance: %s XRP\n", user2Balance) fmt.Printf("User2 initial balance: %s XRP\n", user2Balance)
fmt.Printf("💳 Receiver initial balance: %s XRP\n", receiverBalance) fmt.Printf("Receiver initial balance: %s XRP\n", receiverBalance)
fmt.Println() fmt.Println()
fmt.Printf("Batch transaction test\n") fmt.Printf("Batch transaction test\n")
@@ -103,13 +103,13 @@ func main() {
batchTx.SetAllOrNothingFlag() batchTx.SetAllOrNothingFlag()
flattenedBatchTx := batchTx.Flatten() flattenedBatchTx := batchTx.Flatten()
fmt.Println("Autofilling flattened batch transaction...") fmt.Println("Autofilling flattened batch transaction...")
if err := client.Autofill(&flattenedBatchTx); err != nil { if err := client.Autofill(&flattenedBatchTx); err != nil {
fmt.Println("Autofill error:", err) fmt.Println("Autofill error:", err)
return return
} }
fmt.Println("Signing batch transaction...") fmt.Println("Signing batch transaction...")
response, err := client.SubmitTxAndWait(flattenedBatchTx, &types.SubmitOptions{ response, err := client.SubmitTxAndWait(flattenedBatchTx, &types.SubmitOptions{
Autofill: false, Autofill: false,
Wallet: &userWallet, Wallet: &userWallet,
@@ -119,9 +119,9 @@ func main() {
return return
} }
fmt.Println("Batch transaction submitted") fmt.Println("Batch transaction submitted")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Printf("🌐 Validated: %t\n", response.Validated) fmt.Printf("Validated: %t\n", response.Validated)
fmt.Println() fmt.Println()
// Check final balances // Check final balances
@@ -134,9 +134,9 @@ func main() {
finalReceiverBalance = "0" finalReceiverBalance = "0"
} }
fmt.Printf("💳 User final balance: %s XRP\n", finalUserBalance) fmt.Printf("User final balance: %s XRP\n", finalUserBalance)
fmt.Printf("💳 Receiver final balance: %s XRP\n", finalReceiverBalance) fmt.Printf("Receiver final balance: %s XRP\n", finalReceiverBalance)
fmt.Println() fmt.Println()
fmt.Printf("Multisig Batch transaction test\n") fmt.Printf("Multisig Batch transaction test\n")
@@ -163,13 +163,13 @@ func main() {
multiBatchTx.SetAllOrNothingFlag() multiBatchTx.SetAllOrNothingFlag()
flattenedMultiBatchTx := multiBatchTx.Flatten() flattenedMultiBatchTx := multiBatchTx.Flatten()
fmt.Println("Autofilling flattened multi batch transaction...") fmt.Println("Autofilling flattened multi batch transaction...")
if err := client.AutofillMultisigned(&flattenedMultiBatchTx, 1); err != nil { if err := client.AutofillMultisigned(&flattenedMultiBatchTx, 1); err != nil {
fmt.Println("Autofill error:", err) fmt.Println("Autofill error:", err)
return return
} }
fmt.Println("Signing multi batch transaction...") fmt.Println("Signing multi batch transaction...")
if err := wallet.SignMultiBatch(user2Wallet, &flattenedMultiBatchTx, nil); err != nil { if err := wallet.SignMultiBatch(user2Wallet, &flattenedMultiBatchTx, nil); err != nil {
fmt.Println("Signing error:", err) fmt.Println("Signing error:", err)
return return
@@ -184,9 +184,9 @@ func main() {
return return
} }
fmt.Println("Multisig Batch transaction submitted") fmt.Println("Multisig Batch transaction submitted")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Printf("🌐 Validated: %t\n", response.Validated) fmt.Printf("Validated: %t\n", response.Validated)
fmt.Println() fmt.Println()
// Check final balances // Check final balances
@@ -202,7 +202,7 @@ func main() {
if err != nil { if err != nil {
finalReceiverBalance = "0" finalReceiverBalance = "0"
} }
fmt.Printf("💳 User final balance: %s XRP\n", finalUserBalance) fmt.Printf("User final balance: %s XRP\n", finalUserBalance)
fmt.Printf("💳 User2 final balance: %s XRP\n", finalUser2Balance) fmt.Printf("User2 final balance: %s XRP\n", finalUser2Balance)
fmt.Printf("💳 Receiver final balance: %s XRP\n", finalReceiverBalance) fmt.Printf("Receiver final balance: %s XRP\n", finalReceiverBalance)
} }

View File

@@ -58,7 +58,7 @@ func main() {
return return
} }
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
if err := client.FundWallet(&userWallet); err != nil { if err := client.FundWallet(&userWallet); err != nil {
fmt.Println(err) fmt.Println(err)
return return
@@ -67,7 +67,7 @@ func main() {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallets funded") fmt.Println("Wallets funded")
// Check initial balances // Check initial balances
userBalance, err := client.GetXrpBalance(userWallet.ClassicAddress) userBalance, err := client.GetXrpBalance(userWallet.ClassicAddress)
@@ -84,9 +84,9 @@ func main() {
receiverBalance = "0" receiverBalance = "0"
} }
fmt.Printf("💳 User initial balance: %s XRP\n", userBalance) fmt.Printf("User initial balance: %s XRP\n", userBalance)
fmt.Printf("💳 User2 initial balance: %s XRP\n", user2Balance) fmt.Printf("User2 initial balance: %s XRP\n", user2Balance)
fmt.Printf("💳 Receiver initial balance: %s XRP\n", receiverBalance) fmt.Printf("Receiver initial balance: %s XRP\n", receiverBalance)
fmt.Println() fmt.Println()
fmt.Printf("Batch transaction test\n") fmt.Printf("Batch transaction test\n")
@@ -105,13 +105,13 @@ func main() {
batchTx.SetAllOrNothingFlag() batchTx.SetAllOrNothingFlag()
flattenedBatchTx := batchTx.Flatten() flattenedBatchTx := batchTx.Flatten()
fmt.Println("Autofilling flattened batch transaction...") fmt.Println("Autofilling flattened batch transaction...")
if err := client.Autofill(&flattenedBatchTx); err != nil { if err := client.Autofill(&flattenedBatchTx); err != nil {
fmt.Println("Autofill error:", err) fmt.Println("Autofill error:", err)
return return
} }
fmt.Println("Signing batch transaction...") fmt.Println("Signing batch transaction...")
response, err := client.SubmitTxAndWait(flattenedBatchTx, &types.SubmitOptions{ response, err := client.SubmitTxAndWait(flattenedBatchTx, &types.SubmitOptions{
Autofill: false, Autofill: false,
Wallet: &userWallet, Wallet: &userWallet,
@@ -121,9 +121,9 @@ func main() {
return return
} }
fmt.Println("Batch transaction submitted") fmt.Println("Batch transaction submitted")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Printf("🌐 Validated: %t\n", response.Validated) fmt.Printf("Validated: %t\n", response.Validated)
fmt.Println() fmt.Println()
// Check final balances // Check final balances
@@ -136,9 +136,9 @@ func main() {
finalReceiverBalance = "0" finalReceiverBalance = "0"
} }
fmt.Printf("💳 User final balance: %s XRP\n", finalUserBalance) fmt.Printf("User final balance: %s XRP\n", finalUserBalance)
fmt.Printf("💳 Receiver final balance: %s XRP\n", finalReceiverBalance) fmt.Printf("Receiver final balance: %s XRP\n", finalReceiverBalance)
fmt.Println() fmt.Println()
fmt.Printf("Multisig Batch transaction test\n") fmt.Printf("Multisig Batch transaction test\n")
@@ -165,13 +165,13 @@ func main() {
multiBatchTx.SetAllOrNothingFlag() multiBatchTx.SetAllOrNothingFlag()
flattenedMultiBatchTx := multiBatchTx.Flatten() flattenedMultiBatchTx := multiBatchTx.Flatten()
fmt.Println("Autofilling flattened multi batch transaction...") fmt.Println("Autofilling flattened multi batch transaction...")
if err := client.AutofillMultisigned(&flattenedMultiBatchTx, 1); err != nil { if err := client.AutofillMultisigned(&flattenedMultiBatchTx, 1); err != nil {
fmt.Println("Autofill error:", err) fmt.Println("Autofill error:", err)
return return
} }
fmt.Println("Signing multi batch transaction...") fmt.Println("Signing multi batch transaction...")
if err := wallet.SignMultiBatch(user2Wallet, &flattenedMultiBatchTx, nil); err != nil { if err := wallet.SignMultiBatch(user2Wallet, &flattenedMultiBatchTx, nil); err != nil {
fmt.Println("Signing error:", err) fmt.Println("Signing error:", err)
return return
@@ -186,9 +186,9 @@ func main() {
return return
} }
fmt.Println("Multisig Batch transaction submitted") fmt.Println("Multisig Batch transaction submitted")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Printf("🌐 Validated: %t\n", response.Validated) fmt.Printf("Validated: %t\n", response.Validated)
fmt.Println() fmt.Println()
// Check final balances // Check final balances
@@ -204,7 +204,7 @@ func main() {
if err != nil { if err != nil {
finalReceiverBalance = "0" finalReceiverBalance = "0"
} }
fmt.Printf("💳 User final balance: %s XRP\n", finalUserBalance) fmt.Printf("User final balance: %s XRP\n", finalUserBalance)
fmt.Printf("💳 User2 final balance: %s XRP\n", finalUser2Balance) fmt.Printf("User2 final balance: %s XRP\n", finalUser2Balance)
fmt.Printf("💳 Receiver final balance: %s XRP\n", finalReceiverBalance) fmt.Printf("Receiver final balance: %s XRP\n", finalReceiverBalance)
} }

View File

@@ -35,27 +35,27 @@ func main() {
return return
} }
fmt.Println("Setting up wallets...") fmt.Println("Setting up wallets...")
if err := client.FundWallet(&w); err != nil { if err := client.FundWallet(&w); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Sender wallet funded!") fmt.Println("Sender wallet funded!")
if err := client.FundWallet(&receiverWallet); err != nil { if err := client.FundWallet(&receiverWallet); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Receiver wallet funded!") fmt.Println("Receiver wallet funded!")
fmt.Println() fmt.Println()
fmt.Println("Wallets setup complete!") fmt.Println("Wallets setup complete!")
fmt.Println("💳 Sender wallet:", w.ClassicAddress) fmt.Println("Sender wallet:", w.ClassicAddress)
fmt.Println("💳 Receiver wallet:", receiverWallet.ClassicAddress) fmt.Println("Receiver wallet:", receiverWallet.ClassicAddress)
fmt.Println() fmt.Println()
fmt.Println("Creating check...") fmt.Println("Creating check...")
cc := &transaction.CheckCreate{ cc := &transaction.CheckCreate{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w.GetAddress(), Account: w.GetAddress(),
@@ -85,19 +85,19 @@ func main() {
} }
if !res.Validated { if !res.Validated {
fmt.Println("Check creation failed!") fmt.Println("Check creation failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Check created!") fmt.Println("Check created!")
fmt.Printf("🌐 Hash: %s\n", res.Hash.String()) fmt.Printf("Hash: %s\n", res.Hash.String())
fmt.Println() fmt.Println()
meta, ok := res.Meta.(map[string]interface{}) meta, ok := res.Meta.(map[string]interface{})
if !ok { if !ok {
fmt.Println("Meta is not of type TxObjMeta") fmt.Println("Meta is not of type TxObjMeta")
return return
} }
@@ -108,7 +108,7 @@ func main() {
for _, node := range affectedNodes { for _, node := range affectedNodes {
affectedNode, ok := node.(map[string]interface{}) affectedNode, ok := node.(map[string]interface{})
if !ok { if !ok {
fmt.Println("Node is not of type map[string]interface{}") fmt.Println("Node is not of type map[string]interface{}")
return return
} }
@@ -128,7 +128,7 @@ func main() {
return return
} }
fmt.Println("Cashing out check...") fmt.Println("Cashing out check...")
checkCash := &transaction.CheckCash{ checkCash := &transaction.CheckCash{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: receiverWallet.GetAddress(), Account: receiverWallet.GetAddress(),
@@ -156,7 +156,7 @@ func main() {
return return
} }
fmt.Println("Check cashed out!") fmt.Println("Check cashed out!")
fmt.Printf("🌐 Hash: %s\n", res.Hash.String()) fmt.Printf("Hash: %s\n", res.Hash.String())
fmt.Println() fmt.Println()
} }

View File

@@ -13,7 +13,7 @@ import (
) )
func main() { func main() {
fmt.Println("Connecting to testnet...") fmt.Println("Connecting to testnet...")
client := websocket.NewClient( client := websocket.NewClient(
websocket.NewClientConfig(). websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233"). WithHost("wss://s.altnet.rippletest.net:51233").
@@ -27,11 +27,11 @@ func main() {
} }
if !client.IsConnected() { if !client.IsConnected() {
fmt.Println("Failed to connect to testnet") fmt.Println("Failed to connect to testnet")
return return
} }
fmt.Println("Connected to testnet") fmt.Println("Connected to testnet")
fmt.Println() fmt.Println()
w, err := wallet.New(crypto.ED25519()) w, err := wallet.New(crypto.ED25519())
@@ -46,27 +46,27 @@ func main() {
return return
} }
fmt.Println("Setting up wallets...") fmt.Println("Setting up wallets...")
if err := client.FundWallet(&w); err != nil { if err := client.FundWallet(&w); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Sender wallet funded!") fmt.Println("Sender wallet funded!")
if err := client.FundWallet(&receiverWallet); err != nil { if err := client.FundWallet(&receiverWallet); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Receiver wallet funded!") fmt.Println("Receiver wallet funded!")
fmt.Println() fmt.Println()
fmt.Println("Wallets setup complete!") fmt.Println("Wallets setup complete!")
fmt.Println("💳 Sender wallet:", w.ClassicAddress) fmt.Println("Sender wallet:", w.ClassicAddress)
fmt.Println("💳 Receiver wallet:", receiverWallet.ClassicAddress) fmt.Println("Receiver wallet:", receiverWallet.ClassicAddress)
fmt.Println() fmt.Println()
fmt.Println("Creating check...") fmt.Println("Creating check...")
cc := &transaction.CheckCreate{ cc := &transaction.CheckCreate{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w.GetAddress(), Account: w.GetAddress(),
@@ -96,19 +96,19 @@ func main() {
} }
if !res.Validated { if !res.Validated {
fmt.Println("Check creation failed!") fmt.Println("Check creation failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Check created!") fmt.Println("Check created!")
fmt.Printf("🌐 Hash: %s\n", res.Hash.String()) fmt.Printf("Hash: %s\n", res.Hash.String())
fmt.Println() fmt.Println()
meta, ok := res.Meta.(map[string]interface{}) meta, ok := res.Meta.(map[string]interface{})
if !ok { if !ok {
fmt.Println("Meta is not of type TxObjMeta") fmt.Println("Meta is not of type TxObjMeta")
return return
} }
@@ -119,7 +119,7 @@ func main() {
for _, node := range affectedNodes { for _, node := range affectedNodes {
affectedNode, ok := node.(map[string]interface{}) affectedNode, ok := node.(map[string]interface{})
if !ok { if !ok {
fmt.Println("Node is not of type map[string]interface{}") fmt.Println("Node is not of type map[string]interface{}")
return return
} }
@@ -139,7 +139,7 @@ func main() {
return return
} }
fmt.Println("Cashing out check...") fmt.Println("Cashing out check...")
checkCash := &transaction.CheckCash{ checkCash := &transaction.CheckCash{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: receiverWallet.GetAddress(), Account: receiverWallet.GetAddress(),
@@ -167,7 +167,7 @@ func main() {
return return
} }
fmt.Println("Check cashed out!") fmt.Println("Check cashed out!")
fmt.Printf("🌐 Hash: %s\n", res.Hash.String()) fmt.Printf("Hash: %s\n", res.Hash.String())
fmt.Println() fmt.Println()
} }

View File

@@ -32,41 +32,41 @@ func main() {
// //
// Configure wallets // Configure wallets
// //
fmt.Println("Setting up wallets...") fmt.Println("Setting up wallets...")
coldWallet, err := wallet.New(crypto.ED25519()) coldWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating cold wallet: %s\n", err) fmt.Printf("Error creating cold wallet: %s\n", err)
return return
} }
err = client.FundWallet(&coldWallet) err = client.FundWallet(&coldWallet)
if err != nil { if err != nil {
fmt.Printf("Error funding cold wallet: %s\n", err) fmt.Printf("Error funding cold wallet: %s\n", err)
return return
} }
fmt.Println("💸 Cold wallet funded!") fmt.Println("Cold wallet funded!")
hotWallet, err := wallet.New(crypto.ED25519()) hotWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating hot wallet: %s\n", err) fmt.Printf("Error creating hot wallet: %s\n", err)
return return
} }
err = client.FundWallet(&hotWallet) err = client.FundWallet(&hotWallet)
if err != nil { if err != nil {
fmt.Printf("Error funding hot wallet: %s\n", err) fmt.Printf("Error funding hot wallet: %s\n", err)
return return
} }
fmt.Println("💸 Hot wallet funded!") fmt.Println("Hot wallet funded!")
fmt.Println() fmt.Println()
fmt.Println("Wallets setup complete!") fmt.Println("Wallets setup complete!")
fmt.Println("💳 Cold wallet:", coldWallet.ClassicAddress) fmt.Println("Cold wallet:", coldWallet.ClassicAddress)
fmt.Println("💳 Hot wallet:", hotWallet.ClassicAddress) fmt.Println("Hot wallet:", hotWallet.ClassicAddress)
fmt.Println() fmt.Println()
// //
// Configure cold address settings // Configure cold address settings
// //
fmt.Println("Configuring cold address settings...") fmt.Println("Configuring cold address settings...")
coldWalletAccountSet := &transactions.AccountSet{ coldWalletAccountSet := &transactions.AccountSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -85,37 +85,37 @@ func main() {
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err := coldWallet.Sign(flattenedTx) txBlob, _, err := coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err := client.SubmitTxBlobAndWait(txBlob, false) response, err := client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Cold wallet unfreezing failed!") fmt.Println("Cold wallet unfreezing failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Cold address settings configured!") fmt.Println("Cold address settings configured!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Create trust line from hot to cold address // Create trust line from hot to cold address
// //
fmt.Println("Creating trust line from hot to cold address...") fmt.Println("Creating trust line from hot to cold address...")
hotColdTrustSet := &transactions.TrustSet{ hotColdTrustSet := &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(hotWallet.ClassicAddress), Account: types.Address(hotWallet.ClassicAddress),
@@ -130,37 +130,37 @@ func main() {
flattenedTx = hotColdTrustSet.Flatten() flattenedTx = hotColdTrustSet.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = hotWallet.Sign(flattenedTx) txBlob, _, err = hotWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Trust line from hot to cold address creation failed!") fmt.Println("Trust line from hot to cold address creation failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Trust line from hot to cold address created!") fmt.Println("Trust line from hot to cold address created!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Send tokens from cold wallet to hot wallet // Send tokens from cold wallet to hot wallet
// //
fmt.Println("Sending tokens from cold wallet to hot wallet...") fmt.Println("Sending tokens from cold wallet to hot wallet...")
coldToHotPayment := &transactions.Payment{ coldToHotPayment := &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -177,37 +177,37 @@ func main() {
flattenedTx = coldToHotPayment.Flatten() flattenedTx = coldToHotPayment.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = coldWallet.Sign(flattenedTx) txBlob, _, err = coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Tokens not sent from cold wallet to hot wallet!") fmt.Println("Tokens not sent from cold wallet to hot wallet!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Tokens sent from cold wallet to hot wallet!") fmt.Println("Tokens sent from cold wallet to hot wallet!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Claw back tokens from customer one // Claw back tokens from customer one
// //
fmt.Println("Clawing back tokens from hot wallet...") fmt.Println("Clawing back tokens from hot wallet...")
coldWalletClawback := &transactions.Clawback{ coldWalletClawback := &transactions.Clawback{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
@@ -223,29 +223,29 @@ func main() {
flattenedTx = coldWalletClawback.Flatten() flattenedTx = coldWalletClawback.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = coldWallet.Sign(flattenedTx) txBlob, _, err = coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Tokens not clawed back from customer one!") fmt.Println("Tokens not clawed back from customer one!")
fmt.Println("Try again!") fmt.Println("Try again!")
return return
} }
fmt.Println("Tokens clawed back from customer one!") fmt.Println("Tokens clawed back from customer one!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
} }

View File

@@ -19,13 +19,13 @@ func main() {
// //
// Configure client // Configure client
// //
fmt.Println("Setting up client...") fmt.Println("Setting up client...")
client := websocket.NewClient( client := websocket.NewClient(
websocket.NewClientConfig(). websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net"). WithHost("wss://s.altnet.rippletest.net").
WithFaucetProvider(faucet.NewTestnetFaucetProvider()), WithFaucetProvider(faucet.NewTestnetFaucetProvider()),
) )
fmt.Println("Client configured!") fmt.Println("Client configured!")
fmt.Println() fmt.Println()
fmt.Println("Connecting to server...") fmt.Println("Connecting to server...")
@@ -39,41 +39,41 @@ func main() {
// //
// Configure wallets // Configure wallets
// //
fmt.Println("Setting up wallets...") fmt.Println("Setting up wallets...")
coldWallet, err := wallet.New(crypto.ED25519()) coldWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating cold wallet: %s\n", err) fmt.Printf("Error creating cold wallet: %s\n", err)
return return
} }
err = client.FundWallet(&coldWallet) err = client.FundWallet(&coldWallet)
if err != nil { if err != nil {
fmt.Printf("Error funding cold wallet: %s\n", err) fmt.Printf("Error funding cold wallet: %s\n", err)
return return
} }
fmt.Println("💸 Cold wallet funded!") fmt.Println("Cold wallet funded!")
hotWallet, err := wallet.New(crypto.ED25519()) hotWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating hot wallet: %s\n", err) fmt.Printf("Error creating hot wallet: %s\n", err)
return return
} }
err = client.FundWallet(&hotWallet) err = client.FundWallet(&hotWallet)
if err != nil { if err != nil {
fmt.Printf("Error funding hot wallet: %s\n", err) fmt.Printf("Error funding hot wallet: %s\n", err)
return return
} }
fmt.Println("💸 Hot wallet funded!") fmt.Println("Hot wallet funded!")
fmt.Println() fmt.Println()
fmt.Println("Wallets setup complete!") fmt.Println("Wallets setup complete!")
fmt.Println("💳 Cold wallet:", coldWallet.ClassicAddress) fmt.Println("Cold wallet:", coldWallet.ClassicAddress)
fmt.Println("💳 Hot wallet:", hotWallet.ClassicAddress) fmt.Println("Hot wallet:", hotWallet.ClassicAddress)
fmt.Println() fmt.Println()
// //
// Configure cold address settings // Configure cold address settings
// //
fmt.Println("Configuring cold address settings...") fmt.Println("Configuring cold address settings...")
coldWalletAccountSet := &transactions.AccountSet{ coldWalletAccountSet := &transactions.AccountSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -92,37 +92,37 @@ func main() {
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err := coldWallet.Sign(flattenedTx) txBlob, _, err := coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err := client.SubmitTxBlobAndWait(txBlob, false) response, err := client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Cold wallet unfreezing failed!") fmt.Println("Cold wallet unfreezing failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Cold address settings configured!") fmt.Println("Cold address settings configured!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Create trust line from hot to cold address // Create trust line from hot to cold address
// //
fmt.Println("Creating trust line from hot to cold address...") fmt.Println("Creating trust line from hot to cold address...")
hotColdTrustSet := &transactions.TrustSet{ hotColdTrustSet := &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(hotWallet.ClassicAddress), Account: types.Address(hotWallet.ClassicAddress),
@@ -137,37 +137,37 @@ func main() {
flattenedTx = hotColdTrustSet.Flatten() flattenedTx = hotColdTrustSet.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = hotWallet.Sign(flattenedTx) txBlob, _, err = hotWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Trust line from hot to cold address creation failed!") fmt.Println("Trust line from hot to cold address creation failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Trust line from hot to cold address created!") fmt.Println("Trust line from hot to cold address created!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Send tokens from cold wallet to hot wallet // Send tokens from cold wallet to hot wallet
// //
fmt.Println("Sending tokens from cold wallet to hot wallet...") fmt.Println("Sending tokens from cold wallet to hot wallet...")
coldToHotPayment := &transactions.Payment{ coldToHotPayment := &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -184,37 +184,37 @@ func main() {
flattenedTx = coldToHotPayment.Flatten() flattenedTx = coldToHotPayment.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = coldWallet.Sign(flattenedTx) txBlob, _, err = coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Tokens not sent from cold wallet to hot wallet!") fmt.Println("Tokens not sent from cold wallet to hot wallet!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Tokens sent from cold wallet to hot wallet!") fmt.Println("Tokens sent from cold wallet to hot wallet!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Claw back tokens from customer one // Claw back tokens from customer one
// //
fmt.Println("Clawing back tokens from hot wallet...") fmt.Println("Clawing back tokens from hot wallet...")
coldWalletClawback := &transactions.Clawback{ coldWalletClawback := &transactions.Clawback{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
@@ -230,29 +230,29 @@ func main() {
flattenedTx = coldWalletClawback.Flatten() flattenedTx = coldWalletClawback.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = coldWallet.Sign(flattenedTx) txBlob, _, err = coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Tokens not clawed back from customer one!") fmt.Println("Tokens not clawed back from customer one!")
fmt.Println("Try again!") fmt.Println("Try again!")
return return
} }
fmt.Println("Tokens clawed back from customer one!") fmt.Println("Tokens clawed back from customer one!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
} }

View File

@@ -20,47 +20,47 @@ func main() {
// Configure wallets // Configure wallets
// Issuer // Issuer
fmt.Println("Setting up credential issuer wallet...") fmt.Println("Setting up credential issuer wallet...")
issuer, err := wallet.New(crypto.ED25519()) issuer, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating issuer wallet: %s\n", err) fmt.Printf("Error creating issuer wallet: %s\n", err)
return return
} }
err = client.FundWallet(&issuer) err = client.FundWallet(&issuer)
if err != nil { if err != nil {
fmt.Printf("Error funding issuer wallet: %s\n", err) fmt.Printf("Error funding issuer wallet: %s\n", err)
return return
} }
fmt.Printf("Issuer wallet funded: %s\n", issuer.ClassicAddress) fmt.Printf("Issuer wallet funded: %s\n", issuer.ClassicAddress)
// ----------------------------------------------------- // -----------------------------------------------------
// Subject (destination) // Subject (destination)
fmt.Println("Setting up Subject wallet...") fmt.Println("Setting up Subject wallet...")
subjectWallet, err := wallet.New(crypto.ED25519()) subjectWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating subject wallet: %s\n", err) fmt.Printf("Error creating subject wallet: %s\n", err)
return return
} }
err = client.FundWallet(&subjectWallet) err = client.FundWallet(&subjectWallet)
if err != nil { if err != nil {
fmt.Printf("Error funding subject wallet: %s\n", err) fmt.Printf("Error funding subject wallet: %s\n", err)
return return
} }
fmt.Printf("Subject wallet funded: %s\n", subjectWallet.ClassicAddress) fmt.Printf("Subject wallet funded: %s\n", subjectWallet.ClassicAddress)
// ----------------------------------------------------- // -----------------------------------------------------
// Creating the CredentialCreate transaction // Creating the CredentialCreate transaction
fmt.Println("Creating CredentialCreate transaction...") fmt.Println("Creating CredentialCreate transaction...")
expiration, err := rippleTime.IsoTimeToRippleTime(time.Now().Add(time.Hour * 24).Format(time.RFC3339)) expiration, err := rippleTime.IsoTimeToRippleTime(time.Now().Add(time.Hour * 24).Format(time.RFC3339))
credentialType := types.CredentialType("6D795F63726564656E7469616C") credentialType := types.CredentialType("6D795F63726564656E7469616C")
if err != nil { if err != nil {
fmt.Printf("Error converting expiration to ripple time: %s\n", err) fmt.Printf("Error converting expiration to ripple time: %s\n", err)
return return
} }
@@ -79,7 +79,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Creating the CredentialAccept transaction // Creating the CredentialAccept transaction
fmt.Println("Creating CredentialAccept transaction...") fmt.Println("Creating CredentialAccept transaction...")
acceptTxn := &transaction.CredentialAccept{ acceptTxn := &transaction.CredentialAccept{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -94,7 +94,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Creating the CredentialDelete transaction // Creating the CredentialDelete transaction
fmt.Println("Creating CredentialDelete transaction...") fmt.Println("Creating CredentialDelete transaction...")
deleteTxn := &transaction.CredentialDelete{ deleteTxn := &transaction.CredentialDelete{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{

View File

@@ -15,7 +15,7 @@ import (
func main() { func main() {
fmt.Println("Setting up client...") fmt.Println("Setting up client...")
client := clients.GetDevnetWebsocketClient() client := clients.GetDevnetWebsocketClient()
fmt.Println("Connecting to server...") fmt.Println("Connecting to server...")
@@ -24,7 +24,7 @@ func main() {
return return
} }
fmt.Println("Client configured!") fmt.Println("Client configured!")
fmt.Println() fmt.Println()
fmt.Printf("Connection: %t", client.IsConnected()) fmt.Printf("Connection: %t", client.IsConnected())
@@ -33,47 +33,47 @@ func main() {
// Configure wallets // Configure wallets
// Issuer // Issuer
fmt.Println("Setting up credential issuer wallet...") fmt.Println("Setting up credential issuer wallet...")
issuer, err := wallet.New(crypto.ED25519()) issuer, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating issuer wallet: %s\n", err) fmt.Printf("Error creating issuer wallet: %s\n", err)
return return
} }
err = client.FundWallet(&issuer) err = client.FundWallet(&issuer)
if err != nil { if err != nil {
fmt.Printf("Error funding issuer wallet: %s\n", err) fmt.Printf("Error funding issuer wallet: %s\n", err)
return return
} }
fmt.Printf("Issuer wallet funded: %s\n", issuer.ClassicAddress) fmt.Printf("Issuer wallet funded: %s\n", issuer.ClassicAddress)
// ----------------------------------------------------- // -----------------------------------------------------
// Subject (destination) // Subject (destination)
fmt.Println("Setting up Subject wallet...") fmt.Println("Setting up Subject wallet...")
subjectWallet, err := wallet.New(crypto.ED25519()) subjectWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating subject wallet: %s\n", err) fmt.Printf("Error creating subject wallet: %s\n", err)
return return
} }
err = client.FundWallet(&subjectWallet) err = client.FundWallet(&subjectWallet)
if err != nil { if err != nil {
fmt.Printf("Error funding subject wallet: %s\n", err) fmt.Printf("Error funding subject wallet: %s\n", err)
return return
} }
fmt.Printf("Subject wallet funded: %s\n", subjectWallet.ClassicAddress) fmt.Printf("Subject wallet funded: %s\n", subjectWallet.ClassicAddress)
// ----------------------------------------------------- // -----------------------------------------------------
// Creating the CredentialCreate transaction // Creating the CredentialCreate transaction
fmt.Println("Creating CredentialCreate transaction...") fmt.Println("Creating CredentialCreate transaction...")
expiration, err := rippleTime.IsoTimeToRippleTime(time.Now().Add(time.Hour * 24).Format(time.RFC3339)) expiration, err := rippleTime.IsoTimeToRippleTime(time.Now().Add(time.Hour * 24).Format(time.RFC3339))
credentialType := types.CredentialType("6D795F63726564656E7469616C") credentialType := types.CredentialType("6D795F63726564656E7469616C")
if err != nil { if err != nil {
fmt.Printf("Error converting expiration to ripple time: %s\n", err) fmt.Printf("Error converting expiration to ripple time: %s\n", err)
return return
} }
@@ -92,7 +92,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Creating the CredentialAccept transaction // Creating the CredentialAccept transaction
fmt.Println("Creating CredentialAccept transaction...") fmt.Println("Creating CredentialAccept transaction...")
acceptTxn := &transaction.CredentialAccept{ acceptTxn := &transaction.CredentialAccept{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -107,7 +107,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Creating the CredentialDelete transaction // Creating the CredentialDelete transaction
fmt.Println("Creating CredentialDelete transaction...") fmt.Println("Creating CredentialDelete transaction...")
deleteTxn := &transaction.CredentialDelete{ deleteTxn := &transaction.CredentialDelete{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{

View File

@@ -36,7 +36,7 @@ func main() {
return return
} }
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
if err := client.FundWallet(&delegatorWallet); err != nil { if err := client.FundWallet(&delegatorWallet); err != nil {
fmt.Println(err) fmt.Println(err)
return return
@@ -45,7 +45,7 @@ func main() {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallets funded") fmt.Println("Wallets funded")
// Check initial balances // Check initial balances
delegatorBalance, err := client.GetXrpBalance(delegatorWallet.ClassicAddress) delegatorBalance, err := client.GetXrpBalance(delegatorWallet.ClassicAddress)
@@ -57,8 +57,8 @@ func main() {
delegateeBalance = "0" delegateeBalance = "0"
} }
fmt.Printf("💳 Delegator initial balance: %s XRP\n", delegatorBalance) fmt.Printf("Delegator initial balance: %s XRP\n", delegatorBalance)
fmt.Printf("💳 Delegatee initial balance: %s XRP\n", delegateeBalance) fmt.Printf("Delegatee initial balance: %s XRP\n", delegateeBalance)
fmt.Println() fmt.Println()
// Create DelegateSet transaction // Create DelegateSet transaction
@@ -86,9 +86,9 @@ func main() {
return return
} }
fmt.Println("DelegateSet transaction submitted") fmt.Println("DelegateSet transaction submitted")
fmt.Printf("🌐 Hash: %s\n", response.Hash) fmt.Printf("Hash: %s\n", response.Hash)
fmt.Printf("🌐 Validated: %t\n", response.Validated) fmt.Printf("Validated: %t\n", response.Validated)
fmt.Println() fmt.Println()
// Create delegated payment transaction // Create delegated payment transaction
@@ -111,9 +111,9 @@ func main() {
return return
} }
fmt.Println("Delegated payment submitted") fmt.Println("Delegated payment submitted")
fmt.Printf("🌐 Hash: %s\n", response2.Hash) fmt.Printf("Hash: %s\n", response2.Hash)
fmt.Printf("🌐 Validated: %t\n", response2.Validated) fmt.Printf("Validated: %t\n", response2.Validated)
fmt.Println() fmt.Println()
// Check final balances // Check final balances
@@ -126,6 +126,6 @@ func main() {
finalDelegateeBalance = "0" finalDelegateeBalance = "0"
} }
fmt.Printf("💳 Delegator final balance: %s XRP\n", finalDelegatorBalance) fmt.Printf("Delegator final balance: %s XRP\n", finalDelegatorBalance)
fmt.Printf("💳 Delegatee final balance: %s XRP\n", finalDelegateeBalance) fmt.Printf("Delegatee final balance: %s XRP\n", finalDelegateeBalance)
} }

View File

@@ -38,7 +38,7 @@ func main() {
return return
} }
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
if err := client.FundWallet(&delegatorWallet); err != nil { if err := client.FundWallet(&delegatorWallet); err != nil {
fmt.Println(err) fmt.Println(err)
return return
@@ -47,7 +47,7 @@ func main() {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallets funded") fmt.Println("Wallets funded")
// Check initial balances // Check initial balances
delegatorBalance, err := client.GetXrpBalance(delegatorWallet.ClassicAddress) delegatorBalance, err := client.GetXrpBalance(delegatorWallet.ClassicAddress)
@@ -59,8 +59,8 @@ func main() {
delegateeBalance = "0" delegateeBalance = "0"
} }
fmt.Printf("💳 Delegator initial balance: %s XRP\n", delegatorBalance) fmt.Printf("Delegator initial balance: %s XRP\n", delegatorBalance)
fmt.Printf("💳 Delegatee initial balance: %s XRP\n", delegateeBalance) fmt.Printf("Delegatee initial balance: %s XRP\n", delegateeBalance)
fmt.Println() fmt.Println()
// Create DelegateSet transaction // Create DelegateSet transaction
@@ -97,9 +97,9 @@ func main() {
return return
} }
fmt.Println("DelegateSet transaction submitted") fmt.Println("DelegateSet transaction submitted")
fmt.Printf("🌐 Hash: %s\n", response.Hash) fmt.Printf("Hash: %s\n", response.Hash)
fmt.Printf("🌐 Validated: %t\n", response.Validated) fmt.Printf("Validated: %t\n", response.Validated)
fmt.Println() fmt.Println()
// Create delegated payment transaction // Create delegated payment transaction
@@ -131,9 +131,9 @@ func main() {
return return
} }
fmt.Println("Delegated payment submitted") fmt.Println("Delegated payment submitted")
fmt.Printf("🌐 Hash: %s\n", response2.Hash) fmt.Printf("Hash: %s\n", response2.Hash)
fmt.Printf("🌐 Validated: %t\n", response2.Validated) fmt.Printf("Validated: %t\n", response2.Validated)
fmt.Println() fmt.Println()
// Check final balances // Check final balances
@@ -146,6 +146,6 @@ func main() {
finalDelegateeBalance = "0" finalDelegateeBalance = "0"
} }
fmt.Printf("💳 Delegator final balance: %s XRP\n", finalDelegatorBalance) fmt.Printf("Delegator final balance: %s XRP\n", finalDelegatorBalance)
fmt.Printf("💳 Delegatee final balance: %s XRP\n", finalDelegateeBalance) fmt.Printf("Delegatee final balance: %s XRP\n", finalDelegateeBalance)
} }

View File

@@ -21,41 +21,41 @@ func main() {
// Configure wallets // Configure wallets
// Issuer // Issuer
fmt.Println("Setting up credential issuer wallet...") fmt.Println("Setting up credential issuer wallet...")
issuer, err := wallet.New(crypto.ED25519()) issuer, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating credential issuer wallet: %s\n", err) fmt.Printf("Error creating credential issuer wallet: %s\n", err)
return return
} }
err = client.FundWallet(&issuer) err = client.FundWallet(&issuer)
if err != nil { if err != nil {
fmt.Printf("Error funding credential issuer wallet: %s\n", err) fmt.Printf("Error funding credential issuer wallet: %s\n", err)
return return
} }
fmt.Printf("Credential issuer wallet funded: %s\n", issuer.ClassicAddress) fmt.Printf("Credential issuer wallet funded: %s\n", issuer.ClassicAddress)
// ----------------------------------------------------- // -----------------------------------------------------
// Holder 1 // Holder 1
fmt.Println("Setting up holder 1 wallet...") fmt.Println("Setting up holder 1 wallet...")
holderWallet1, err := wallet.New(crypto.ED25519()) holderWallet1, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating holder 1 wallet: %s\n", err) fmt.Printf("Error creating holder 1 wallet: %s\n", err)
return return
} }
err = client.FundWallet(&holderWallet1) err = client.FundWallet(&holderWallet1)
if err != nil { if err != nil {
fmt.Printf("Error funding holder 1 wallet: %s\n", err) fmt.Printf("Error funding holder 1 wallet: %s\n", err)
return return
} }
fmt.Printf("Holder 1 wallet funded: %s\n", holderWallet1.ClassicAddress) fmt.Printf("Holder 1 wallet funded: %s\n", holderWallet1.ClassicAddress)
// ----------------------------------------------------- // -----------------------------------------------------
// Enabling DepositAuth on the issuer account with an AccountSet transaction // Enabling DepositAuth on the issuer account with an AccountSet transaction
fmt.Println("Enabling DepositAuth on the issuer account...") fmt.Println("Enabling DepositAuth on the issuer account...")
accountSetTx := &transaction.AccountSet{ accountSetTx := &transaction.AccountSet{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: issuer.ClassicAddress, Account: issuer.ClassicAddress,
@@ -69,11 +69,11 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Creating the CredentialCreate transaction // Creating the CredentialCreate transaction
fmt.Println("Creating the CredentialCreate transaction...") fmt.Println("Creating the CredentialCreate transaction...")
expiration, err := rippletime.IsoTimeToRippleTime(time.Now().Add(time.Hour * 24).Format(time.RFC3339)) expiration, err := rippletime.IsoTimeToRippleTime(time.Now().Add(time.Hour * 24).Format(time.RFC3339))
if err != nil { if err != nil {
fmt.Printf("Error converting expiration to ripple time: %s\n", err) fmt.Printf("Error converting expiration to ripple time: %s\n", err)
return return
} }
credentialType := types.CredentialType("6D795F63726564656E7469616C") // my_credential credentialType := types.CredentialType("6D795F63726564656E7469616C") // my_credential
@@ -94,7 +94,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Creating the CredentialAccept transaction // Creating the CredentialAccept transaction
fmt.Println("Creating the CredentialAccept transaction...") fmt.Println("Creating the CredentialAccept transaction...")
credentialAcceptTx := &transaction.CredentialAccept{ credentialAcceptTx := &transaction.CredentialAccept{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -110,7 +110,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Creating the DepositPreauth transaction // Creating the DepositPreauth transaction
fmt.Println("Creating the DepositPreauth transaction using AuthorizeCredentials...") fmt.Println("Creating the DepositPreauth transaction using AuthorizeCredentials...")
depositPreauthTx := &transaction.DepositPreauth{ depositPreauthTx := &transaction.DepositPreauth{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -132,7 +132,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Get the credential ID // Get the credential ID
fmt.Println("Getting the credential ID from the holder 1 account...") fmt.Println("Getting the credential ID from the holder 1 account...")
objectsRequest := &account.ObjectsRequest{ objectsRequest := &account.ObjectsRequest{
Account: holderWallet1.ClassicAddress, Account: holderWallet1.ClassicAddress,
@@ -142,30 +142,30 @@ func main() {
objectsResponse, err := client.GetAccountObjects(objectsRequest) objectsResponse, err := client.GetAccountObjects(objectsRequest)
if err != nil { if err != nil {
fmt.Printf("Error getting the credential ID: %s\n", err) fmt.Printf("Error getting the credential ID: %s\n", err)
return return
} }
// Check if we have any credential objects // Check if we have any credential objects
if len(objectsResponse.AccountObjects) == 0 { if len(objectsResponse.AccountObjects) == 0 {
fmt.Println("No credential objects found") fmt.Println("No credential objects found")
return return
} }
// Extract the credential ID // Extract the credential ID
credentialID, ok := objectsResponse.AccountObjects[0]["index"].(string) credentialID, ok := objectsResponse.AccountObjects[0]["index"].(string)
if !ok { if !ok {
fmt.Println("Could not extract credential ID from response") fmt.Println("Could not extract credential ID from response")
return return
} }
fmt.Printf("Credential ID: %s\n", credentialID) fmt.Printf("Credential ID: %s\n", credentialID)
fmt.Println() fmt.Println()
// ----------------------------------------------------- // -----------------------------------------------------
// Sending XRP to the holder 1 account // Sending XRP to the holder 1 account
fmt.Println("Sending XRP to the issuer account, should succeed...") fmt.Println("Sending XRP to the issuer account, should succeed...")
sendTx := &transaction.Payment{ sendTx := &transaction.Payment{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -182,7 +182,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Unauthorizing the holder 1 account // Unauthorizing the holder 1 account
fmt.Println("Unauthorizing the holder 1 account with the DepositPreauth transaction and the UnauthorizeCredentials field...") fmt.Println("Unauthorizing the holder 1 account with the DepositPreauth transaction and the UnauthorizeCredentials field...")
unauthorizeTx := &transaction.DepositPreauth{ unauthorizeTx := &transaction.DepositPreauth{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -204,7 +204,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Sending XRP to the holder 1 account again (which should fail) // Sending XRP to the holder 1 account again (which should fail)
fmt.Println("Sending XRP to the issuer account again (which should fail)...") fmt.Println("Sending XRP to the issuer account again (which should fail)...")
sendTx2 := &transaction.Payment{ sendTx2 := &transaction.Payment{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{

View File

@@ -17,7 +17,7 @@ import (
func main() { func main() {
fmt.Println("Setting up client...") fmt.Println("Setting up client...")
client := clients.GetDevnetWebsocketClient() client := clients.GetDevnetWebsocketClient()
fmt.Println("Connecting to server...") fmt.Println("Connecting to server...")
@@ -26,7 +26,7 @@ func main() {
return return
} }
fmt.Println("Client configured!") fmt.Println("Client configured!")
fmt.Println() fmt.Println()
fmt.Printf("Connection: %t", client.IsConnected()) fmt.Printf("Connection: %t", client.IsConnected())
@@ -35,41 +35,41 @@ func main() {
// Configure wallets // Configure wallets
// Issuer // Issuer
fmt.Println("Setting up credential issuer wallet...") fmt.Println("Setting up credential issuer wallet...")
issuer, err := wallet.New(crypto.ED25519()) issuer, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating credential issuer wallet: %s\n", err) fmt.Printf("Error creating credential issuer wallet: %s\n", err)
return return
} }
err = client.FundWallet(&issuer) err = client.FundWallet(&issuer)
if err != nil { if err != nil {
fmt.Printf("Error funding credential issuer wallet: %s\n", err) fmt.Printf("Error funding credential issuer wallet: %s\n", err)
return return
} }
fmt.Printf("Credential issuer wallet funded: %s\n", issuer.ClassicAddress) fmt.Printf("Credential issuer wallet funded: %s\n", issuer.ClassicAddress)
// ----------------------------------------------------- // -----------------------------------------------------
// Holder 1 // Holder 1
fmt.Println("Setting up holder 1 wallet...") fmt.Println("Setting up holder 1 wallet...")
holderWallet1, err := wallet.New(crypto.ED25519()) holderWallet1, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating holder 1 wallet: %s\n", err) fmt.Printf("Error creating holder 1 wallet: %s\n", err)
return return
} }
err = client.FundWallet(&holderWallet1) err = client.FundWallet(&holderWallet1)
if err != nil { if err != nil {
fmt.Printf("Error funding holder 1 wallet: %s\n", err) fmt.Printf("Error funding holder 1 wallet: %s\n", err)
return return
} }
fmt.Printf("Holder 1 wallet funded: %s\n", holderWallet1.ClassicAddress) fmt.Printf("Holder 1 wallet funded: %s\n", holderWallet1.ClassicAddress)
// ----------------------------------------------------- // -----------------------------------------------------
// Enabling DepositAuth on the issuer account with an AccountSet transaction // Enabling DepositAuth on the issuer account with an AccountSet transaction
fmt.Println("Enabling DepositAuth on the issuer account...") fmt.Println("Enabling DepositAuth on the issuer account...")
accountSetTx := &transaction.AccountSet{ accountSetTx := &transaction.AccountSet{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: issuer.ClassicAddress, Account: issuer.ClassicAddress,
@@ -83,11 +83,11 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Creating the CredentialCreate transaction // Creating the CredentialCreate transaction
fmt.Println("Creating the CredentialCreate transaction...") fmt.Println("Creating the CredentialCreate transaction...")
expiration, err := rippletime.IsoTimeToRippleTime(time.Now().Add(time.Hour * 24).Format(time.RFC3339)) expiration, err := rippletime.IsoTimeToRippleTime(time.Now().Add(time.Hour * 24).Format(time.RFC3339))
if err != nil { if err != nil {
fmt.Printf("Error converting expiration to ripple time: %s\n", err) fmt.Printf("Error converting expiration to ripple time: %s\n", err)
return return
} }
credentialType := types.CredentialType("6D795F63726564656E7469616C") // my_credential credentialType := types.CredentialType("6D795F63726564656E7469616C") // my_credential
@@ -108,7 +108,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Creating the CredentialAccept transaction // Creating the CredentialAccept transaction
fmt.Println("Creating the CredentialAccept transaction...") fmt.Println("Creating the CredentialAccept transaction...")
credentialAcceptTx := &transaction.CredentialAccept{ credentialAcceptTx := &transaction.CredentialAccept{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -124,7 +124,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Creating the DepositPreauth transaction // Creating the DepositPreauth transaction
fmt.Println("Creating the DepositPreauth transaction using AuthorizeCredentials...") fmt.Println("Creating the DepositPreauth transaction using AuthorizeCredentials...")
depositPreauthTx := &transaction.DepositPreauth{ depositPreauthTx := &transaction.DepositPreauth{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -146,7 +146,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Get the credential ID // Get the credential ID
fmt.Println("Getting the credential ID from the holder 1 account...") fmt.Println("Getting the credential ID from the holder 1 account...")
objectsRequest := &account.ObjectsRequest{ objectsRequest := &account.ObjectsRequest{
Account: holderWallet1.ClassicAddress, Account: holderWallet1.ClassicAddress,
@@ -156,30 +156,30 @@ func main() {
objectsResponse, err := client.GetAccountObjects(objectsRequest) objectsResponse, err := client.GetAccountObjects(objectsRequest)
if err != nil { if err != nil {
fmt.Printf("Error getting the credential ID: %s\n", err) fmt.Printf("Error getting the credential ID: %s\n", err)
return return
} }
// Check if we have any credential objects // Check if we have any credential objects
if len(objectsResponse.AccountObjects) == 0 { if len(objectsResponse.AccountObjects) == 0 {
fmt.Println("No credential objects found") fmt.Println("No credential objects found")
return return
} }
// Extract the credential ID // Extract the credential ID
credentialID, ok := objectsResponse.AccountObjects[0]["index"].(string) credentialID, ok := objectsResponse.AccountObjects[0]["index"].(string)
if !ok { if !ok {
fmt.Println("Could not extract credential ID from response") fmt.Println("Could not extract credential ID from response")
return return
} }
fmt.Printf("Credential ID: %s\n", credentialID) fmt.Printf("Credential ID: %s\n", credentialID)
fmt.Println() fmt.Println()
// ----------------------------------------------------- // -----------------------------------------------------
// Sending XRP to the holder 1 account // Sending XRP to the holder 1 account
fmt.Println("Sending XRP to the issuer account, should succeed...") fmt.Println("Sending XRP to the issuer account, should succeed...")
sendTx := &transaction.Payment{ sendTx := &transaction.Payment{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -196,7 +196,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Unauthorize the holder 1 account // Unauthorize the holder 1 account
fmt.Println("Unauthorize the holder 1 account with the DepositPreauth transaction and the UnauthorizeCredentials field...") fmt.Println("Unauthorize the holder 1 account with the DepositPreauth transaction and the UnauthorizeCredentials field...")
unauthorizeTx := &transaction.DepositPreauth{ unauthorizeTx := &transaction.DepositPreauth{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -218,7 +218,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Sending XRP to the holder 1 account again (which should fail) // Sending XRP to the holder 1 account again (which should fail)
fmt.Println("Sending XRP to the issuer account again (which should fail)...") fmt.Println("Sending XRP to the issuer account again (which should fail)...")
sendTx2 := &transaction.Payment{ sendTx2 := &transaction.Payment{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{

View File

@@ -27,62 +27,62 @@ func main() {
// Configure wallets // Configure wallets
// Issuer // Issuer
fmt.Println("Setting up issuer wallet...") fmt.Println("Setting up issuer wallet...")
issuer, err := wallet.New(crypto.ED25519()) issuer, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating issuer wallet: %s\n", err) fmt.Printf("Error creating issuer wallet: %s\n", err)
return return
} }
err = client.FundWallet(&issuer) err = client.FundWallet(&issuer)
if err != nil { if err != nil {
fmt.Printf("Error funding issuer wallet: %s\n", err) fmt.Printf("Error funding issuer wallet: %s\n", err)
return return
} }
fmt.Printf("Issuer wallet funded: %s\n", issuer.ClassicAddress) fmt.Printf("Issuer wallet funded: %s\n", issuer.ClassicAddress)
// ----------------------------------------------------- // -----------------------------------------------------
// Holder 1 // Holder 1
fmt.Println("Setting up holder 1 wallet...") fmt.Println("Setting up holder 1 wallet...")
holderWallet1, err := wallet.New(crypto.ED25519()) holderWallet1, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating holder wallet 1: %s\n", err) fmt.Printf("Error creating holder wallet 1: %s\n", err)
return return
} }
err = client.FundWallet(&holderWallet1) err = client.FundWallet(&holderWallet1)
if err != nil { if err != nil {
fmt.Printf("Error funding holder wallet 1: %s\n", err) fmt.Printf("Error funding holder wallet 1: %s\n", err)
return return
} }
fmt.Printf("Holder wallet 1 funded: %s\n", holderWallet1.ClassicAddress) fmt.Printf("Holder wallet 1 funded: %s\n", holderWallet1.ClassicAddress)
// ----------------------------------------------------- // -----------------------------------------------------
// Holder 2 // Holder 2
fmt.Println("Setting up holder 2 wallet...") fmt.Println("Setting up holder 2 wallet...")
holderWallet2, err := wallet.New(crypto.ED25519()) holderWallet2, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating holder wallet 2: %s\n", err) fmt.Printf("Error creating holder wallet 2: %s\n", err)
return return
} }
err = client.FundWallet(&holderWallet2) err = client.FundWallet(&holderWallet2)
if err != nil { if err != nil {
fmt.Printf("Error funding holder wallet 2: %s\n", err) fmt.Printf("Error funding holder wallet 2: %s\n", err)
return return
} }
fmt.Printf("Holder wallet 2 funded: %s\n", holderWallet2.ClassicAddress) fmt.Printf("Holder wallet 2 funded: %s\n", holderWallet2.ClassicAddress)
fmt.Println() fmt.Println()
fmt.Println("Wallets setup complete!") fmt.Println("Wallets setup complete!")
fmt.Println() fmt.Println()
// ----------------------------------------------------- // -----------------------------------------------------
// Configuring Issuing account // Configuring Issuing account
fmt.Println("Configuring issuer address settings...") fmt.Println("Configuring issuer address settings...")
accountSet := &transactions.AccountSet{ accountSet := &transactions.AccountSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(issuer.ClassicAddress), Account: types.Address(issuer.ClassicAddress),
@@ -96,7 +96,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Trustline from the holder 1 to the issuer // Trustline from the holder 1 to the issuer
fmt.Println("Setting up trustline from holder 1 to the issuer...") fmt.Println("Setting up trustline from holder 1 to the issuer...")
trustSet := &transactions.TrustSet{ trustSet := &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet1.ClassicAddress), Account: types.Address(holderWallet1.ClassicAddress),
@@ -112,7 +112,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Trustline from the holder 2 to the issuer // Trustline from the holder 2 to the issuer
fmt.Println("Setting up trustline from holder 2 to the issuer...") fmt.Println("Setting up trustline from holder 2 to the issuer...")
trustSet = &transactions.TrustSet{ trustSet = &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet2.ClassicAddress), Account: types.Address(holderWallet2.ClassicAddress),
@@ -129,7 +129,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Minting to Holder 1 // Minting to Holder 1
fmt.Println("Minting to Holder 1...") fmt.Println("Minting to Holder 1...")
payment := &transactions.Payment{ payment := &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(issuer.ClassicAddress), Account: types.Address(issuer.ClassicAddress),
@@ -146,7 +146,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Minting to Holder 2 // Minting to Holder 2
fmt.Println("Minting to Holder 2...") fmt.Println("Minting to Holder 2...")
payment = &transactions.Payment{ payment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(issuer.ClassicAddress), Account: types.Address(issuer.ClassicAddress),
@@ -163,7 +163,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Sending payment from Holder 1 to Holder 2 // Sending payment from Holder 1 to Holder 2
fmt.Println("Sending payment from Holder 1 to Holder 2...") fmt.Println("Sending payment from Holder 1 to Holder 2...")
payment = &transactions.Payment{ payment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet1.ClassicAddress), Account: types.Address(holderWallet1.ClassicAddress),
@@ -180,7 +180,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Freezing and Deep Freezing holder1 // Freezing and Deep Freezing holder1
fmt.Println("Freezing and Deep Freezing holder 1 trustline...") fmt.Println("Freezing and Deep Freezing holder 1 trustline...")
trustSet = &transactions.TrustSet{ trustSet = &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(issuer.ClassicAddress), Account: types.Address(issuer.ClassicAddress),
@@ -196,10 +196,10 @@ func main() {
submitAndWait(client, trustSet, issuer) submitAndWait(client, trustSet, issuer)
// ------------------- SHOULD FAIL ⬇️ ------------------ // ------------------- SHOULD FAIL ------------------
// Sending payment from Holder 1 to Holder 2 (which should fail), Holder 1 can't decrease its balance // Sending payment from Holder 1 to Holder 2 (which should fail), Holder 1 can't decrease its balance
fmt.Println("Sending payment from Holder 1 to Holder 2 (which should fail). Holder 1 can't decrease its balance...") fmt.Println("Sending payment from Holder 1 to Holder 2 (which should fail). Holder 1 can't decrease its balance...")
payment = &transactions.Payment{ payment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet1.ClassicAddress), Account: types.Address(holderWallet1.ClassicAddress),
@@ -213,10 +213,10 @@ func main() {
} }
submitAndWait(client, payment, holderWallet1) submitAndWait(client, payment, holderWallet1)
// ------------------- SHOULD FAIL ⬇️ ------------------ // ------------------- SHOULD FAIL ------------------
// Sending payment from Holder 2 to Holder 1 (which should fail), Holder 1 can't increase its balance // Sending payment from Holder 2 to Holder 1 (which should fail), Holder 1 can't increase its balance
fmt.Println("Sending payment from Holder 2 to Holder 1 (which should fail). Holder 1 can't increase its balance...") fmt.Println("Sending payment from Holder 2 to Holder 1 (which should fail). Holder 1 can't increase its balance...")
payment = &transactions.Payment{ payment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet2.ClassicAddress), Account: types.Address(holderWallet2.ClassicAddress),
@@ -230,10 +230,10 @@ func main() {
} }
submitAndWait(client, payment, holderWallet2) submitAndWait(client, payment, holderWallet2)
// ------------------- SHOULD FAIL ⬇️ ------------------ // ------------------- SHOULD FAIL ------------------
// Creating OfferCreate transaction (which should fail), Holder 1 can't create an offer // Creating OfferCreate transaction (which should fail), Holder 1 can't create an offer
fmt.Println("Creating OfferCreate transaction (which should fail). Holder 1 can't create an offer...") fmt.Println("Creating OfferCreate transaction (which should fail). Holder 1 can't create an offer...")
offerCreate := &transactions.OfferCreate{ offerCreate := &transactions.OfferCreate{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet1.ClassicAddress), Account: types.Address(holderWallet1.ClassicAddress),
@@ -250,7 +250,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Unfreezing and Deep Unfreezing holder 1 // Unfreezing and Deep Unfreezing holder 1
fmt.Println("Unfreezing and Deep Unfreezing holder 1 trustline...") fmt.Println("Unfreezing and Deep Unfreezing holder 1 trustline...")
trustSet = &transactions.TrustSet{ trustSet = &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(issuer.ClassicAddress), Account: types.Address(issuer.ClassicAddress),
@@ -268,7 +268,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Sending payment from Holder 1 to Holder 2 (which should succeed), Holder 1 can decrease its balance // Sending payment from Holder 1 to Holder 2 (which should succeed), Holder 1 can decrease its balance
fmt.Println("Sending payment from Holder 1 to Holder 2 (which should succeed). Holder 1 can decrease its balance...") fmt.Println("Sending payment from Holder 1 to Holder 2 (which should succeed). Holder 1 can decrease its balance...")
payment = &transactions.Payment{ payment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet1.ClassicAddress), Account: types.Address(holderWallet1.ClassicAddress),
@@ -285,7 +285,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Sending payment from Holder 2 to Holder 1 (which should succeed), Holder 1 can increase its balance // Sending payment from Holder 2 to Holder 1 (which should succeed), Holder 1 can increase its balance
fmt.Println("Sending payment from Holder 2 to Holder 1 (which should succeed). Holder 1 can increase its balance...") fmt.Println("Sending payment from Holder 2 to Holder 1 (which should succeed). Holder 1 can increase its balance...")
payment = &transactions.Payment{ payment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet2.ClassicAddress), Account: types.Address(holderWallet2.ClassicAddress),
@@ -316,32 +316,32 @@ func getRpcClient() *rpc.Client {
// submitAndWait submits a transaction and waits for it to be included in a validated ledger // submitAndWait submits a transaction and waits for it to be included in a validated ledger
func submitAndWait(client *rpc.Client, txn SubmittableTransaction, wallet wallet.Wallet) { func submitAndWait(client *rpc.Client, txn SubmittableTransaction, wallet wallet.Wallet) {
fmt.Printf("Submitting %s transaction...\n", txn.TxType()) fmt.Printf("Submitting %s transaction...\n", txn.TxType())
flattenedTx := txn.Flatten() flattenedTx := txn.Flatten()
err := client.Autofill(&flattenedTx) err := client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling %s transaction: %s\n", txn.TxType(), err) fmt.Printf("Error autofilling %s transaction: %s\n", txn.TxType(), err)
fmt.Println() fmt.Println()
return return
} }
txBlob, _, err := wallet.Sign(flattenedTx) txBlob, _, err := wallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing %s transaction: %s\n", txn.TxType(), err) fmt.Printf("Error signing %s transaction: %s\n", txn.TxType(), err)
fmt.Println() fmt.Println()
return return
} }
response, err := client.SubmitTxBlobAndWait(txBlob, false) response, err := client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting %s transaction: %s\n", txn.TxType(), err) fmt.Printf("Error submitting %s transaction: %s\n", txn.TxType(), err)
fmt.Println() fmt.Println()
return return
} }
fmt.Printf("%s transaction submitted\n", txn.TxType()) fmt.Printf("%s transaction submitted\n", txn.TxType())
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
} }

View File

@@ -22,7 +22,7 @@ type SubmittableTransaction interface {
} }
func main() { func main() {
fmt.Println("Setting up client...") fmt.Println("Setting up client...")
client := getClient() client := getClient()
fmt.Println("Connecting to server...") fmt.Println("Connecting to server...")
@@ -31,7 +31,7 @@ func main() {
return return
} }
fmt.Println("Client configured!") fmt.Println("Client configured!")
fmt.Println() fmt.Println()
fmt.Printf("Connection: %t", client.IsConnected()) fmt.Printf("Connection: %t", client.IsConnected())
@@ -40,62 +40,62 @@ func main() {
// Configure wallets // Configure wallets
// Issuer // Issuer
fmt.Println("Setting up issuer wallet...") fmt.Println("Setting up issuer wallet...")
issuer, err := wallet.New(crypto.ED25519()) issuer, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating issuer wallet: %s\n", err) fmt.Printf("Error creating issuer wallet: %s\n", err)
return return
} }
err = client.FundWallet(&issuer) err = client.FundWallet(&issuer)
if err != nil { if err != nil {
fmt.Printf("Error funding issuer wallet: %s\n", err) fmt.Printf("Error funding issuer wallet: %s\n", err)
return return
} }
fmt.Printf("Issuer wallet funded: %s\n", issuer.ClassicAddress) fmt.Printf("Issuer wallet funded: %s\n", issuer.ClassicAddress)
// ----------------------------------------------------- // -----------------------------------------------------
// Holder 1 // Holder 1
fmt.Println("Setting up holder 1 wallet...") fmt.Println("Setting up holder 1 wallet...")
holderWallet1, err := wallet.New(crypto.ED25519()) holderWallet1, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating holder wallet 1: %s\n", err) fmt.Printf("Error creating holder wallet 1: %s\n", err)
return return
} }
err = client.FundWallet(&holderWallet1) err = client.FundWallet(&holderWallet1)
if err != nil { if err != nil {
fmt.Printf("Error funding holder wallet 1: %s\n", err) fmt.Printf("Error funding holder wallet 1: %s\n", err)
return return
} }
fmt.Printf("Holder wallet 1 funded: %s\n", holderWallet1.ClassicAddress) fmt.Printf("Holder wallet 1 funded: %s\n", holderWallet1.ClassicAddress)
// ----------------------------------------------------- // -----------------------------------------------------
// Holder 2 // Holder 2
fmt.Println("Setting up holder 2 wallet...") fmt.Println("Setting up holder 2 wallet...")
holderWallet2, err := wallet.New(crypto.ED25519()) holderWallet2, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating holder wallet 2: %s\n", err) fmt.Printf("Error creating holder wallet 2: %s\n", err)
return return
} }
err = client.FundWallet(&holderWallet2) err = client.FundWallet(&holderWallet2)
if err != nil { if err != nil {
fmt.Printf("Error funding holder wallet 2: %s\n", err) fmt.Printf("Error funding holder wallet 2: %s\n", err)
return return
} }
fmt.Printf("Holder wallet 2 funded: %s\n", holderWallet2.ClassicAddress) fmt.Printf("Holder wallet 2 funded: %s\n", holderWallet2.ClassicAddress)
fmt.Println() fmt.Println()
fmt.Println("Wallets setup complete!") fmt.Println("Wallets setup complete!")
fmt.Println() fmt.Println()
// ----------------------------------------------------- // -----------------------------------------------------
// Configuring Issuing account // Configuring Issuing account
fmt.Println("Configuring issuer address settings...") fmt.Println("Configuring issuer address settings...")
accountSet := &transactions.AccountSet{ accountSet := &transactions.AccountSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(issuer.ClassicAddress), Account: types.Address(issuer.ClassicAddress),
@@ -109,7 +109,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Trustline from the holder 1 to the issuer // Trustline from the holder 1 to the issuer
fmt.Println("Setting up trustline from holder 1 to the issuer...") fmt.Println("Setting up trustline from holder 1 to the issuer...")
trustSet := &transactions.TrustSet{ trustSet := &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet1.ClassicAddress), Account: types.Address(holderWallet1.ClassicAddress),
@@ -125,7 +125,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Trustline from the holder 2 to the issuer // Trustline from the holder 2 to the issuer
fmt.Println("Setting up trustline from holder 2 to the issuer...") fmt.Println("Setting up trustline from holder 2 to the issuer...")
trustSet = &transactions.TrustSet{ trustSet = &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet2.ClassicAddress), Account: types.Address(holderWallet2.ClassicAddress),
@@ -142,7 +142,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Minting to Holder 1 // Minting to Holder 1
fmt.Println("Minting to Holder 1...") fmt.Println("Minting to Holder 1...")
payment := &transactions.Payment{ payment := &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(issuer.ClassicAddress), Account: types.Address(issuer.ClassicAddress),
@@ -159,7 +159,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Minting to Holder 2 // Minting to Holder 2
fmt.Println("Minting to Holder 2...") fmt.Println("Minting to Holder 2...")
payment = &transactions.Payment{ payment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(issuer.ClassicAddress), Account: types.Address(issuer.ClassicAddress),
@@ -176,7 +176,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Sending payment from Holder 1 to Holder 2 // Sending payment from Holder 1 to Holder 2
fmt.Println("Sending payment from Holder 1 to Holder 2...") fmt.Println("Sending payment from Holder 1 to Holder 2...")
payment = &transactions.Payment{ payment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet1.ClassicAddress), Account: types.Address(holderWallet1.ClassicAddress),
@@ -193,7 +193,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Freezing and Deep Freezing holder1 // Freezing and Deep Freezing holder1
fmt.Println("Freezing and Deep Freezing holder 1 trustline...") fmt.Println("Freezing and Deep Freezing holder 1 trustline...")
trustSet = &transactions.TrustSet{ trustSet = &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(issuer.ClassicAddress), Account: types.Address(issuer.ClassicAddress),
@@ -209,10 +209,10 @@ func main() {
submitAndWait(client, trustSet, issuer) submitAndWait(client, trustSet, issuer)
// ------------------- SHOULD FAIL ⬇️ ------------------ // ------------------- SHOULD FAIL ------------------
// Sending payment from Holder 1 to Holder 2 (which should fail), Holder 1 can't decrease its balance // Sending payment from Holder 1 to Holder 2 (which should fail), Holder 1 can't decrease its balance
fmt.Println("Sending payment from Holder 1 to Holder 2 (which should fail). Holder 1 can't decrease its balance...") fmt.Println("Sending payment from Holder 1 to Holder 2 (which should fail). Holder 1 can't decrease its balance...")
payment = &transactions.Payment{ payment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet1.ClassicAddress), Account: types.Address(holderWallet1.ClassicAddress),
@@ -226,10 +226,10 @@ func main() {
} }
submitAndWait(client, payment, holderWallet1) submitAndWait(client, payment, holderWallet1)
// ------------------- SHOULD FAIL ⬇️ ------------------ // ------------------- SHOULD FAIL ------------------
// Sending payment from Holder 2 to Holder 1 (which should fail), Holder 1 can't increase its balance // Sending payment from Holder 2 to Holder 1 (which should fail), Holder 1 can't increase its balance
fmt.Println("Sending payment from Holder 2 to Holder 1 (which should fail). Holder 1 can't increase its balance...") fmt.Println("Sending payment from Holder 2 to Holder 1 (which should fail). Holder 1 can't increase its balance...")
payment = &transactions.Payment{ payment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet2.ClassicAddress), Account: types.Address(holderWallet2.ClassicAddress),
@@ -243,10 +243,10 @@ func main() {
} }
submitAndWait(client, payment, holderWallet2) submitAndWait(client, payment, holderWallet2)
// ------------------- SHOULD FAIL ⬇️ ------------------ // ------------------- SHOULD FAIL ------------------
// Creating OfferCreate transaction (which should fail), Holder 1 can't create an offer // Creating OfferCreate transaction (which should fail), Holder 1 can't create an offer
fmt.Println("Creating OfferCreate transaction (which should fail). Holder 1 can't create an offer...") fmt.Println("Creating OfferCreate transaction (which should fail). Holder 1 can't create an offer...")
offerCreate := &transactions.OfferCreate{ offerCreate := &transactions.OfferCreate{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet1.ClassicAddress), Account: types.Address(holderWallet1.ClassicAddress),
@@ -263,7 +263,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Unfreezing and Deep Unfreezing holder 1 // Unfreezing and Deep Unfreezing holder 1
fmt.Println("Unfreezing and Deep Unfreezing holder 1 trustline...") fmt.Println("Unfreezing and Deep Unfreezing holder 1 trustline...")
trustSet = &transactions.TrustSet{ trustSet = &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(issuer.ClassicAddress), Account: types.Address(issuer.ClassicAddress),
@@ -281,7 +281,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Sending payment from Holder 1 to Holder 2 (which should succeed), Holder 1 can decrease its balance // Sending payment from Holder 1 to Holder 2 (which should succeed), Holder 1 can decrease its balance
fmt.Println("Sending payment from Holder 1 to Holder 2 (which should succeed). Holder 1 can decrease its balance...") fmt.Println("Sending payment from Holder 1 to Holder 2 (which should succeed). Holder 1 can decrease its balance...")
payment = &transactions.Payment{ payment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet1.ClassicAddress), Account: types.Address(holderWallet1.ClassicAddress),
@@ -298,7 +298,7 @@ func main() {
// ----------------------------------------------------- // -----------------------------------------------------
// Sending payment from Holder 2 to Holder 1 (which should succeed), Holder 1 can increase its balance // Sending payment from Holder 2 to Holder 1 (which should succeed), Holder 1 can increase its balance
fmt.Println("Sending payment from Holder 2 to Holder 1 (which should succeed). Holder 1 can increase its balance...") fmt.Println("Sending payment from Holder 2 to Holder 1 (which should succeed). Holder 1 can increase its balance...")
payment = &transactions.Payment{ payment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(holderWallet2.ClassicAddress), Account: types.Address(holderWallet2.ClassicAddress),
@@ -326,32 +326,32 @@ func getClient() *websocket.Client {
// submitAndWait submits a transaction and waits for it to be included in a validated ledger // submitAndWait submits a transaction and waits for it to be included in a validated ledger
func submitAndWait(client *websocket.Client, txn SubmittableTransaction, wallet wallet.Wallet) { func submitAndWait(client *websocket.Client, txn SubmittableTransaction, wallet wallet.Wallet) {
fmt.Printf("Submitting %s transaction...\n", txn.TxType()) fmt.Printf("Submitting %s transaction...\n", txn.TxType())
flattenedTx := txn.Flatten() flattenedTx := txn.Flatten()
err := client.Autofill(&flattenedTx) err := client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling %s transaction: %s\n", txn.TxType(), err) fmt.Printf("Error autofilling %s transaction: %s\n", txn.TxType(), err)
fmt.Println() fmt.Println()
return return
} }
txBlob, _, err := wallet.Sign(flattenedTx) txBlob, _, err := wallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing %s transaction: %s\n", txn.TxType(), err) fmt.Printf("Error signing %s transaction: %s\n", txn.TxType(), err)
fmt.Println() fmt.Println()
return return
} }
response, err := client.SubmitTxBlobAndWait(txBlob, false) response, err := client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting %s transaction: %s\n", txn.TxType(), err) fmt.Printf("Error submitting %s transaction: %s\n", txn.TxType(), err)
fmt.Println() fmt.Println()
return return
} }
fmt.Printf("%s transaction submitted\n", txn.TxType()) fmt.Printf("%s transaction submitted\n", txn.TxType())
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
} }

View File

@@ -1,6 +1,7 @@
package main package main
import ( import (
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/queries/utility" "github.com/Peersyst/xrpl-go/xrpl/queries/utility"
"github.com/Peersyst/xrpl-go/xrpl/rpc" "github.com/Peersyst/xrpl-go/xrpl/rpc"
) )

View File

@@ -3,6 +3,7 @@ package main
import ( import (
"fmt" "fmt"
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/websocket" "github.com/Peersyst/xrpl-go/xrpl/websocket"
) )

View File

@@ -31,11 +31,11 @@ func main() {
} }
if !client.IsConnected() { if !client.IsConnected() {
fmt.Println("Failed to connect to testnet") fmt.Println("Failed to connect to testnet")
return return
} }
fmt.Println("Connected to testnet") fmt.Println("Connected to testnet")
fmt.Println() fmt.Println()
// Create a new wallet // Create a new wallet

View File

@@ -19,7 +19,7 @@ func main() {
// //
// Configure client // Configure client
// //
fmt.Println("Setting up client...") fmt.Println("Setting up client...")
cfg, err := rpc.NewClientConfig( cfg, err := rpc.NewClientConfig(
"https://s.altnet.rippletest.net:51234/", "https://s.altnet.rippletest.net:51234/",
rpc.WithFaucetProvider(faucet.NewTestnetFaucetProvider()), rpc.WithFaucetProvider(faucet.NewTestnetFaucetProvider()),
@@ -29,60 +29,60 @@ func main() {
} }
client := rpc.NewClient(cfg) client := rpc.NewClient(cfg)
fmt.Println("Client configured!") fmt.Println("Client configured!")
fmt.Println() fmt.Println()
// //
// Configure wallets // Configure wallets
// //
fmt.Println("Setting up wallets...") fmt.Println("Setting up wallets...")
coldWallet, err := wallet.New(crypto.ED25519()) coldWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating cold wallet: %s\n", err) fmt.Printf("Error creating cold wallet: %s\n", err)
return return
} }
err = client.FundWallet(&coldWallet) err = client.FundWallet(&coldWallet)
if err != nil { if err != nil {
fmt.Printf("Error funding cold wallet: %s\n", err) fmt.Printf("Error funding cold wallet: %s\n", err)
return return
} }
fmt.Println("💸 Cold wallet funded!") fmt.Println("Cold wallet funded!")
hotWallet, err := wallet.New(crypto.ED25519()) hotWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating hot wallet: %s\n", err) fmt.Printf("Error creating hot wallet: %s\n", err)
return return
} }
err = client.FundWallet(&hotWallet) err = client.FundWallet(&hotWallet)
if err != nil { if err != nil {
fmt.Printf("Error funding hot wallet: %s\n", err) fmt.Printf("Error funding hot wallet: %s\n", err)
return return
} }
fmt.Println("💸 Hot wallet funded!") fmt.Println("Hot wallet funded!")
customerOneWallet, err := wallet.New(crypto.ED25519()) customerOneWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating token wallet: %s\n", err) fmt.Printf("Error creating token wallet: %s\n", err)
return return
} }
err = client.FundWallet(&customerOneWallet) err = client.FundWallet(&customerOneWallet)
if err != nil { if err != nil {
fmt.Printf("Error funding customer one wallet: %s\n", err) fmt.Printf("Error funding customer one wallet: %s\n", err)
return return
} }
fmt.Println("💸 Customer one wallet funded!") fmt.Println("Customer one wallet funded!")
fmt.Println() fmt.Println()
fmt.Println("Wallets setup complete!") fmt.Println("Wallets setup complete!")
fmt.Println("💳 Cold wallet:", coldWallet.ClassicAddress) fmt.Println("Cold wallet:", coldWallet.ClassicAddress)
fmt.Println("💳 Hot wallet:", hotWallet.ClassicAddress) fmt.Println("Hot wallet:", hotWallet.ClassicAddress)
fmt.Println("💳 Customer one wallet:", customerOneWallet.ClassicAddress) fmt.Println("Customer one wallet:", customerOneWallet.ClassicAddress)
fmt.Println() fmt.Println()
// //
// Configure cold address settings // Configure cold address settings
// //
fmt.Println("Configuring cold address settings...") fmt.Println("Configuring cold address settings...")
coldWalletAccountSet := &transactions.AccountSet{ coldWalletAccountSet := &transactions.AccountSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -101,37 +101,37 @@ func main() {
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err := coldWallet.Sign(flattenedTx) txBlob, _, err := coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err := client.SubmitTxBlobAndWait(txBlob, false) response, err := client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Cold address settings configuration failed!") fmt.Println("Cold address settings configuration failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Cold address settings configured!") fmt.Println("Cold address settings configured!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Configure hot address settings // Configure hot address settings
// //
fmt.Println("Configuring hot address settings...") fmt.Println("Configuring hot address settings...")
hotWalletAccountSet := &transactions.AccountSet{ hotWalletAccountSet := &transactions.AccountSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(hotWallet.ClassicAddress), Account: types.Address(hotWallet.ClassicAddress),
@@ -146,37 +146,37 @@ func main() {
flattenedTx = hotWalletAccountSet.Flatten() flattenedTx = hotWalletAccountSet.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = hotWallet.Sign(flattenedTx) txBlob, _, err = hotWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Hot address settings configuration failed!") fmt.Println("Hot address settings configuration failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Hot address settings configured!") fmt.Println("Hot address settings configured!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Create trust line from hot to cold address // Create trust line from hot to cold address
// //
fmt.Println("Creating trust line from hot to cold address...") fmt.Println("Creating trust line from hot to cold address...")
hotColdTrustSet := &transactions.TrustSet{ hotColdTrustSet := &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(hotWallet.ClassicAddress), Account: types.Address(hotWallet.ClassicAddress),
@@ -191,37 +191,37 @@ func main() {
flattenedTx = hotColdTrustSet.Flatten() flattenedTx = hotColdTrustSet.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = hotWallet.Sign(flattenedTx) txBlob, _, err = hotWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Trust line from hot to cold address creation failed!") fmt.Println("Trust line from hot to cold address creation failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Trust line from hot to cold address created!") fmt.Println("Trust line from hot to cold address created!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Create trust line from costumer one to cold address // Create trust line from costumer one to cold address
// //
fmt.Println("Creating trust line from customer one to cold address...") fmt.Println("Creating trust line from customer one to cold address...")
customerOneColdTrustSet := &transactions.TrustSet{ customerOneColdTrustSet := &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(customerOneWallet.ClassicAddress), Account: types.Address(customerOneWallet.ClassicAddress),
@@ -236,37 +236,37 @@ func main() {
flattenedTx = customerOneColdTrustSet.Flatten() flattenedTx = customerOneColdTrustSet.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = customerOneWallet.Sign(flattenedTx) txBlob, _, err = customerOneWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Trust line from customer one to cold address creation failed!") fmt.Println("Trust line from customer one to cold address creation failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Trust line from customer one to cold address created!") fmt.Println("Trust line from customer one to cold address created!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Send tokens from cold wallet to hot wallet // Send tokens from cold wallet to hot wallet
// //
fmt.Println("Sending tokens from cold wallet to hot wallet...") fmt.Println("Sending tokens from cold wallet to hot wallet...")
coldToHotPayment := &transactions.Payment{ coldToHotPayment := &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -283,37 +283,37 @@ func main() {
flattenedTx = coldToHotPayment.Flatten() flattenedTx = coldToHotPayment.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = coldWallet.Sign(flattenedTx) txBlob, _, err = coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Tokens not sent from cold wallet to hot wallet!") fmt.Println("Tokens not sent from cold wallet to hot wallet!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Tokens sent from cold wallet to hot wallet!") fmt.Println("Tokens sent from cold wallet to hot wallet!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Send tokens from hot wallet to customer one // Send tokens from hot wallet to customer one
// //
fmt.Println("Sending tokens from cold wallet to customer one...") fmt.Println("Sending tokens from cold wallet to customer one...")
coldToCustomerOnePayment := &transactions.Payment{ coldToCustomerOnePayment := &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -329,36 +329,36 @@ func main() {
flattenedTx = coldToCustomerOnePayment.Flatten() flattenedTx = coldToCustomerOnePayment.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = coldWallet.Sign(flattenedTx) txBlob, _, err = coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Tokens not sent from cold wallet to customer one!") fmt.Println("Tokens not sent from cold wallet to customer one!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Tokens sent from cold wallet to customer one!") fmt.Println("Tokens sent from cold wallet to customer one!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Freeze cold wallet // Freeze cold wallet
// //
fmt.Println("Freezing cold wallet...") fmt.Println("Freezing cold wallet...")
freezeColdWallet := &transactions.AccountSet{ freezeColdWallet := &transactions.AccountSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -370,37 +370,37 @@ func main() {
flattenedTx = freezeColdWallet.Flatten() flattenedTx = freezeColdWallet.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = coldWallet.Sign(flattenedTx) txBlob, _, err = coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Cold wallet freezing failed!") fmt.Println("Cold wallet freezing failed!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Cold wallet frozen!") fmt.Println("Cold wallet frozen!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Try to send tokens from hot wallet to customer one // Try to send tokens from hot wallet to customer one
// //
fmt.Println("Trying to send tokens from hot wallet to customer one...") fmt.Println("Trying to send tokens from hot wallet to customer one...")
hotToCustomerOnePayment := &transactions.Payment{ hotToCustomerOnePayment := &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(hotWallet.ClassicAddress), Account: types.Address(hotWallet.ClassicAddress),
@@ -416,13 +416,13 @@ func main() {
flattenedTx = hotToCustomerOnePayment.Flatten() flattenedTx = hotToCustomerOnePayment.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = hotWallet.Sign(flattenedTx) txBlob, _, err = hotWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
@@ -431,13 +431,13 @@ func main() {
return return
} }
fmt.Println("Tokens not sent from hot wallet to customer one!") fmt.Println("Tokens not sent from hot wallet to customer one!")
fmt.Println() fmt.Println()
// // // //
// // Unfreeze cold wallet // // Unfreeze cold wallet
// // // //
fmt.Println("Unfreezing cold wallet...") fmt.Println("Unfreezing cold wallet...")
unfreezeColdWallet := &transactions.AccountSet{ unfreezeColdWallet := &transactions.AccountSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -449,37 +449,37 @@ func main() {
flattenedTx = unfreezeColdWallet.Flatten() flattenedTx = unfreezeColdWallet.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = coldWallet.Sign(flattenedTx) txBlob, _, err = coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Cold wallet unfreezing failed!") fmt.Println("Cold wallet unfreezing failed!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Cold wallet unfrozen!") fmt.Println("Cold wallet unfrozen!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Try to send tokens from hot wallet to customer one // Try to send tokens from hot wallet to customer one
// //
fmt.Println("Trying to send tokens from hot wallet to customer one...") fmt.Println("Trying to send tokens from hot wallet to customer one...")
hotToCustomerOnePayment = &transactions.Payment{ hotToCustomerOnePayment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(hotWallet.ClassicAddress), Account: types.Address(hotWallet.ClassicAddress),
@@ -495,29 +495,29 @@ func main() {
flattenedTx = hotToCustomerOnePayment.Flatten() flattenedTx = hotToCustomerOnePayment.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = hotWallet.Sign(flattenedTx) txBlob, _, err = hotWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Tokens not sent from hot wallet to customer one!") fmt.Println("Tokens not sent from hot wallet to customer one!")
fmt.Println("Try again!") fmt.Println("Try again!")
return return
} }
fmt.Println("Tokens sent from hot wallet to customer one!") fmt.Println("Tokens sent from hot wallet to customer one!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
} }

View File

@@ -19,14 +19,14 @@ func main() {
// //
// Configure client // Configure client
// //
fmt.Println("Setting up client...") fmt.Println("Setting up client...")
client := websocket.NewClient( client := websocket.NewClient(
websocket.NewClientConfig(). websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net"). WithHost("wss://s.altnet.rippletest.net").
WithFaucetProvider(faucet.NewTestnetFaucetProvider()), WithFaucetProvider(faucet.NewTestnetFaucetProvider()),
) )
defer client.Disconnect() defer client.Disconnect()
fmt.Println("Client configured!") fmt.Println("Client configured!")
fmt.Println() fmt.Println()
fmt.Println("Connecting to server...") fmt.Println("Connecting to server...")
@@ -41,54 +41,54 @@ func main() {
// //
// Configure wallets // Configure wallets
// //
fmt.Println("Setting up wallets...") fmt.Println("Setting up wallets...")
coldWallet, err := wallet.New(crypto.ED25519()) coldWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating cold wallet: %s\n", err) fmt.Printf("Error creating cold wallet: %s\n", err)
return return
} }
err = client.FundWallet(&coldWallet) err = client.FundWallet(&coldWallet)
if err != nil { if err != nil {
fmt.Printf("Error funding cold wallet: %s\n", err) fmt.Printf("Error funding cold wallet: %s\n", err)
return return
} }
fmt.Println("💸 Cold wallet funded!") fmt.Println("Cold wallet funded!")
hotWallet, err := wallet.New(crypto.ED25519()) hotWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating hot wallet: %s\n", err) fmt.Printf("Error creating hot wallet: %s\n", err)
return return
} }
err = client.FundWallet(&hotWallet) err = client.FundWallet(&hotWallet)
if err != nil { if err != nil {
fmt.Printf("Error funding hot wallet: %s\n", err) fmt.Printf("Error funding hot wallet: %s\n", err)
return return
} }
fmt.Println("💸 Hot wallet funded!") fmt.Println("Hot wallet funded!")
customerOneWallet, err := wallet.New(crypto.ED25519()) customerOneWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Printf("Error creating token wallet: %s\n", err) fmt.Printf("Error creating token wallet: %s\n", err)
return return
} }
err = client.FundWallet(&customerOneWallet) err = client.FundWallet(&customerOneWallet)
if err != nil { if err != nil {
fmt.Printf("Error funding customer one wallet: %s\n", err) fmt.Printf("Error funding customer one wallet: %s\n", err)
return return
} }
fmt.Println("💸 Customer one wallet funded!") fmt.Println("Customer one wallet funded!")
fmt.Println() fmt.Println()
fmt.Println("Wallets setup complete!") fmt.Println("Wallets setup complete!")
fmt.Println("💳 Cold wallet:", coldWallet.ClassicAddress) fmt.Println("Cold wallet:", coldWallet.ClassicAddress)
fmt.Println("💳 Hot wallet:", hotWallet.ClassicAddress) fmt.Println("Hot wallet:", hotWallet.ClassicAddress)
fmt.Println("💳 Customer one wallet:", customerOneWallet.ClassicAddress) fmt.Println("Customer one wallet:", customerOneWallet.ClassicAddress)
fmt.Println() fmt.Println()
// //
// Configure cold address settings // Configure cold address settings
// //
fmt.Println("Configuring cold address settings...") fmt.Println("Configuring cold address settings...")
coldWalletAccountSet := &transactions.AccountSet{ coldWalletAccountSet := &transactions.AccountSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -107,37 +107,37 @@ func main() {
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err := coldWallet.Sign(flattenedTx) txBlob, _, err := coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err := client.SubmitTxBlobAndWait(txBlob, false) response, err := client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Cold address settings configuration failed!") fmt.Println("Cold address settings configuration failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Cold address settings configured!") fmt.Println("Cold address settings configured!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Configure hot address settings // Configure hot address settings
// //
fmt.Println("Configuring hot address settings...") fmt.Println("Configuring hot address settings...")
hotWalletAccountSet := &transactions.AccountSet{ hotWalletAccountSet := &transactions.AccountSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(hotWallet.ClassicAddress), Account: types.Address(hotWallet.ClassicAddress),
@@ -152,37 +152,37 @@ func main() {
flattenedTx = hotWalletAccountSet.Flatten() flattenedTx = hotWalletAccountSet.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = hotWallet.Sign(flattenedTx) txBlob, _, err = hotWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Hot address settings configuration failed!") fmt.Println("Hot address settings configuration failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Hot address settings configured!") fmt.Println("Hot address settings configured!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Create trust line from hot to cold address // Create trust line from hot to cold address
// //
fmt.Println("Creating trust line from hot to cold address...") fmt.Println("Creating trust line from hot to cold address...")
hotColdTrustSet := &transactions.TrustSet{ hotColdTrustSet := &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(hotWallet.ClassicAddress), Account: types.Address(hotWallet.ClassicAddress),
@@ -197,37 +197,37 @@ func main() {
flattenedTx = hotColdTrustSet.Flatten() flattenedTx = hotColdTrustSet.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = hotWallet.Sign(flattenedTx) txBlob, _, err = hotWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Trust line from hot to cold address creation failed!") fmt.Println("Trust line from hot to cold address creation failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Trust line from hot to cold address created!") fmt.Println("Trust line from hot to cold address created!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Create trust line from costumer one to cold address // Create trust line from costumer one to cold address
// //
fmt.Println("Creating trust line from customer one to cold address...") fmt.Println("Creating trust line from customer one to cold address...")
customerOneColdTrustSet := &transactions.TrustSet{ customerOneColdTrustSet := &transactions.TrustSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(customerOneWallet.ClassicAddress), Account: types.Address(customerOneWallet.ClassicAddress),
@@ -242,37 +242,37 @@ func main() {
flattenedTx = customerOneColdTrustSet.Flatten() flattenedTx = customerOneColdTrustSet.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = customerOneWallet.Sign(flattenedTx) txBlob, _, err = customerOneWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Trust line from customer one to cold address creation failed!") fmt.Println("Trust line from customer one to cold address creation failed!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Trust line from customer one to cold address created!") fmt.Println("Trust line from customer one to cold address created!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Send tokens from cold wallet to hot wallet // Send tokens from cold wallet to hot wallet
// //
fmt.Println("Sending tokens from cold wallet to hot wallet...") fmt.Println("Sending tokens from cold wallet to hot wallet...")
coldToHotPayment := &transactions.Payment{ coldToHotPayment := &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -289,37 +289,37 @@ func main() {
flattenedTx = coldToHotPayment.Flatten() flattenedTx = coldToHotPayment.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = coldWallet.Sign(flattenedTx) txBlob, _, err = coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Tokens not sent from cold wallet to hot wallet!") fmt.Println("Tokens not sent from cold wallet to hot wallet!")
fmt.Println("Try again!") fmt.Println("Try again!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Tokens sent from cold wallet to hot wallet!") fmt.Println("Tokens sent from cold wallet to hot wallet!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Send tokens from hot wallet to customer one // Send tokens from hot wallet to customer one
// //
fmt.Println("Sending tokens from cold wallet to customer one...") fmt.Println("Sending tokens from cold wallet to customer one...")
coldToCustomerOnePayment := &transactions.Payment{ coldToCustomerOnePayment := &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -335,36 +335,36 @@ func main() {
flattenedTx = coldToCustomerOnePayment.Flatten() flattenedTx = coldToCustomerOnePayment.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = coldWallet.Sign(flattenedTx) txBlob, _, err = coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Tokens not sent from cold wallet to customer one!") fmt.Println("Tokens not sent from cold wallet to customer one!")
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Tokens sent from cold wallet to customer one!") fmt.Println("Tokens sent from cold wallet to customer one!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Freeze cold wallet // Freeze cold wallet
// //
fmt.Println("Freezing cold wallet...") fmt.Println("Freezing cold wallet...")
freezeColdWallet := &transactions.AccountSet{ freezeColdWallet := &transactions.AccountSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -376,37 +376,37 @@ func main() {
flattenedTx = freezeColdWallet.Flatten() flattenedTx = freezeColdWallet.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = coldWallet.Sign(flattenedTx) txBlob, _, err = coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Cold wallet freezing failed!") fmt.Println("Cold wallet freezing failed!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Cold wallet frozen!") fmt.Println("Cold wallet frozen!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Try to send tokens from hot wallet to customer one // Try to send tokens from hot wallet to customer one
// //
fmt.Println("Trying to send tokens from hot wallet to customer one...") fmt.Println("Trying to send tokens from hot wallet to customer one...")
hotToCustomerOnePayment := &transactions.Payment{ hotToCustomerOnePayment := &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(hotWallet.ClassicAddress), Account: types.Address(hotWallet.ClassicAddress),
@@ -422,13 +422,13 @@ func main() {
flattenedTx = hotToCustomerOnePayment.Flatten() flattenedTx = hotToCustomerOnePayment.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = hotWallet.Sign(flattenedTx) txBlob, _, err = hotWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
@@ -437,13 +437,13 @@ func main() {
return return
} }
fmt.Println("Tokens not sent from hot wallet to customer one!") fmt.Println("Tokens not sent from hot wallet to customer one!")
fmt.Println() fmt.Println()
// // // //
// // Unfreeze cold wallet // // Unfreeze cold wallet
// // // //
fmt.Println("Unfreezing cold wallet...") fmt.Println("Unfreezing cold wallet...")
unfreezeColdWallet := &transactions.AccountSet{ unfreezeColdWallet := &transactions.AccountSet{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(coldWallet.ClassicAddress), Account: types.Address(coldWallet.ClassicAddress),
@@ -455,37 +455,37 @@ func main() {
flattenedTx = unfreezeColdWallet.Flatten() flattenedTx = unfreezeColdWallet.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = coldWallet.Sign(flattenedTx) txBlob, _, err = coldWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Cold wallet unfreezing failed!") fmt.Println("Cold wallet unfreezing failed!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
return return
} }
fmt.Println("Cold wallet unfrozen!") fmt.Println("Cold wallet unfrozen!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
// //
// Try to send tokens from hot wallet to customer one // Try to send tokens from hot wallet to customer one
// //
fmt.Println("Trying to send tokens from hot wallet to customer one...") fmt.Println("Trying to send tokens from hot wallet to customer one...")
hotToCustomerOnePayment = &transactions.Payment{ hotToCustomerOnePayment = &transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(hotWallet.ClassicAddress), Account: types.Address(hotWallet.ClassicAddress),
@@ -501,29 +501,29 @@ func main() {
flattenedTx = hotToCustomerOnePayment.Flatten() flattenedTx = hotToCustomerOnePayment.Flatten()
err = client.Autofill(&flattenedTx) err = client.Autofill(&flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error autofilling transaction: %s\n", err) fmt.Printf("Error autofilling transaction: %s\n", err)
return return
} }
txBlob, _, err = hotWallet.Sign(flattenedTx) txBlob, _, err = hotWallet.Sign(flattenedTx)
if err != nil { if err != nil {
fmt.Printf("Error signing transaction: %s\n", err) fmt.Printf("Error signing transaction: %s\n", err)
return return
} }
response, err = client.SubmitTxBlobAndWait(txBlob, false) response, err = client.SubmitTxBlobAndWait(txBlob, false)
if err != nil { if err != nil {
fmt.Printf("Error submitting transaction: %s\n", err) fmt.Printf("Error submitting transaction: %s\n", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("Tokens not sent from hot wallet to customer one!") fmt.Println("Tokens not sent from hot wallet to customer one!")
fmt.Println("Try again!") fmt.Println("Try again!")
return return
} }
fmt.Println("Tokens sent from hot wallet to customer one!") fmt.Println("Tokens sent from hot wallet to customer one!")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Println() fmt.Println()
} }

View File

@@ -44,28 +44,28 @@ func main() {
return return
} }
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
if err := client.FundWallet(&w1); err != nil { if err := client.FundWallet(&w1); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet 1 funded") fmt.Println("Wallet 1 funded")
if err := client.FundWallet(&w2); err != nil { if err := client.FundWallet(&w2); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet 2 funded") fmt.Println("Wallet 2 funded")
if err := client.FundWallet(&master); err != nil { if err := client.FundWallet(&master); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Master wallet funded") fmt.Println("Master wallet funded")
fmt.Println() fmt.Println()
fmt.Println("Setting up signer list...") fmt.Println("Setting up signer list...")
ss := &transaction.SignerListSet{ ss := &transaction.SignerListSet{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -113,11 +113,11 @@ func main() {
return return
} }
fmt.Println("SignerListSet transaction submitted!") fmt.Println("SignerListSet transaction submitted!")
fmt.Printf("🌐 Hash: %s\n", res.Hash.String()) fmt.Printf("Hash: %s\n", res.Hash.String())
fmt.Println() fmt.Println()
fmt.Println("Setting up AccountSet multisign transaction...") fmt.Println("Setting up AccountSet multisign transaction...")
as := &transaction.AccountSet{ as := &transaction.AccountSet{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -161,6 +161,6 @@ func main() {
return return
} }
fmt.Println("Multisigned transaction submitted!") fmt.Println("Multisigned transaction submitted!")
fmt.Printf("🌐 Result: %s\n", mRes.EngineResult) fmt.Printf("Result: %s\n", mRes.EngineResult)
} }

View File

@@ -16,7 +16,7 @@ import (
) )
func main() { func main() {
fmt.Println("Connecting to testnet...") fmt.Println("Connecting to testnet...")
client := websocket.NewClient( client := websocket.NewClient(
websocket.NewClientConfig(). websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233"). WithHost("wss://s.altnet.rippletest.net:51233").
@@ -30,11 +30,11 @@ func main() {
} }
if !client.IsConnected() { if !client.IsConnected() {
fmt.Println("Failed to connect to testnet") fmt.Println("Failed to connect to testnet")
return return
} }
fmt.Println("Connected to testnet") fmt.Println("Connected to testnet")
fmt.Println() fmt.Println()
w1, err := wallet.FromSeed("sEdTtvLmJmrb7GaivhWoXRkvU4NDjVf", "") w1, err := wallet.FromSeed("sEdTtvLmJmrb7GaivhWoXRkvU4NDjVf", "")
@@ -55,28 +55,28 @@ func main() {
return return
} }
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
if err := client.FundWallet(&w1); err != nil { if err := client.FundWallet(&w1); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet 1 funded") fmt.Println("Wallet 1 funded")
if err := client.FundWallet(&w2); err != nil { if err := client.FundWallet(&w2); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet 2 funded") fmt.Println("Wallet 2 funded")
if err := client.FundWallet(&master); err != nil { if err := client.FundWallet(&master); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Master wallet funded") fmt.Println("Master wallet funded")
fmt.Println() fmt.Println()
fmt.Println("Setting up signer list...") fmt.Println("Setting up signer list...")
ss := &transaction.SignerListSet{ ss := &transaction.SignerListSet{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -105,34 +105,34 @@ func main() {
}, },
} }
fmt.Println("Flattening transaction...") fmt.Println("Flattening transaction...")
flatSs := ss.Flatten() flatSs := ss.Flatten()
fmt.Println("Autofilling transaction...") fmt.Println("Autofilling transaction...")
if err := client.Autofill(&flatSs); err != nil { if err := client.Autofill(&flatSs); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("Signing transaction...") fmt.Println("Signing transaction...")
blob, _, err := master.Sign(flatSs) blob, _, err := master.Sign(flatSs)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("Submitting transaction...") fmt.Println("Submitting transaction...")
res, err := client.SubmitTxBlobAndWait(blob, false) res, err := client.SubmitTxBlobAndWait(blob, false)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("SignerListSet transaction submitted!") fmt.Println("SignerListSet transaction submitted!")
fmt.Printf("🌐 Hash: %s\n", res.Hash.String()) fmt.Printf("Hash: %s\n", res.Hash.String())
fmt.Println() fmt.Println()
fmt.Println("Setting up AccountSet multisign transaction...") fmt.Println("Setting up AccountSet multisign transaction...")
as := &transaction.AccountSet{ as := &transaction.AccountSet{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -176,6 +176,6 @@ func main() {
return return
} }
fmt.Println("Multisigned transaction submitted!") fmt.Println("Multisigned transaction submitted!")
fmt.Printf("🌐 Result: %s\n", mRes.EngineResult) fmt.Printf("Result: %s\n", mRes.EngineResult)
} }

View File

@@ -26,35 +26,35 @@ func main() {
client := rpc.NewClient(cfg) client := rpc.NewClient(cfg)
// Step 1: Fund wallets // Step 1: Fund wallets
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
// Create and fund the NFT minter wallet // Create and fund the NFT minter wallet
nftMinter, err := wallet.New(crypto.ED25519()) nftMinter, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Println("Error creating NFT minter wallet:", err) fmt.Println("Error creating NFT minter wallet:", err)
return return
} }
if err := client.FundWallet(&nftMinter); err != nil { if err := client.FundWallet(&nftMinter); err != nil {
fmt.Println("Error funding NFT minter wallet:", err) fmt.Println("Error funding NFT minter wallet:", err)
return return
} }
fmt.Println("💸 NFT minter wallet funded!") fmt.Println("NFT minter wallet funded!")
// Create and fund the NFT buyer wallet // Create and fund the NFT buyer wallet
nftBuyer, err := wallet.New(crypto.ED25519()) nftBuyer, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Println("Error creating NFT buyer wallet:", err) fmt.Println("Error creating NFT buyer wallet:", err)
return return
} }
if err := client.FundWallet(&nftBuyer); err != nil { if err := client.FundWallet(&nftBuyer); err != nil {
fmt.Println("Error funding NFT buyer wallet:", err) fmt.Println("Error funding NFT buyer wallet:", err)
return return
} }
fmt.Println("💸 NFT buyer wallet funded!") fmt.Println("NFT buyer wallet funded!")
fmt.Println() fmt.Println()
// Step 2: Mint an NFT // Step 2: Mint an NFT
fmt.Println("Minting NFT...") fmt.Println("Minting NFT...")
nftMint := transaction.NFTokenMint{ nftMint := transaction.NFTokenMint{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -73,36 +73,36 @@ func main() {
Wallet: &nftMinter, Wallet: &nftMinter,
}) })
if err != nil { if err != nil {
fmt.Println("Error minting NFT:", err) fmt.Println("Error minting NFT:", err)
return return
} }
if !responseMint.Validated { if !responseMint.Validated {
fmt.Println("NFTokenMint txn is not in a validated ledger", responseMint) fmt.Println("NFTokenMint txn is not in a validated ledger", responseMint)
return return
} }
fmt.Println("NFT minted successfully! - 🌎 Hash: ", responseMint.Hash) fmt.Println("NFT minted successfully! - Hash: ", responseMint.Hash)
fmt.Println() fmt.Println()
// Step 3: Retrieve the NFT token offer ID // Step 3: Retrieve the NFT token offer ID
fmt.Println("Retrieving NFT offer ID...") fmt.Println("Retrieving NFT offer ID...")
metaMap, ok := responseMint.Meta.(map[string]any) metaMap, ok := responseMint.Meta.(map[string]any)
if !ok { if !ok {
fmt.Println("Meta is not a map[string]any") fmt.Println("Meta is not a map[string]any")
return return
} }
offerID, ok := metaMap["offer_id"].(string) offerID, ok := metaMap["offer_id"].(string)
if !ok { if !ok {
fmt.Println("offer_id not found or not a string") fmt.Println("offer_id not found or not a string")
return return
} }
fmt.Println("🌎 offer_id:", offerID) fmt.Println("offer_id:", offerID)
fmt.Println() fmt.Println()
// Step 4: Accept the NFT offer // Step 4: Accept the NFT offer
fmt.Println("Accepting NFT offer...") fmt.Println("Accepting NFT offer...")
nftAccept := transaction.NFTokenAcceptOffer{ nftAccept := transaction.NFTokenAcceptOffer{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -117,12 +117,12 @@ func main() {
Wallet: &nftBuyer, Wallet: &nftBuyer,
}) })
if err != nil { if err != nil {
fmt.Println("Error accepting NFT offer:", err) fmt.Println("Error accepting NFT offer:", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("NFTokenAcceptOffer txn is not in a validated ledger", response) fmt.Println("NFTokenAcceptOffer txn is not in a validated ledger", response)
return return
} }
fmt.Println("NFT offer accepted successfully! - 🌎 Hash: ", response.Hash) fmt.Println("NFT offer accepted successfully! - Hash: ", response.Hash)
} }

View File

@@ -14,7 +14,7 @@ import (
func main() { func main() {
// Connect to the XRPL devnet // Connect to the XRPL devnet
fmt.Println("Connecting to devnet...") fmt.Println("Connecting to devnet...")
client := websocket.NewClient( client := websocket.NewClient(
websocket.NewClientConfig(). websocket.NewClientConfig().
WithHost("wss://s.devnet.rippletest.net:51233"). WithHost("wss://s.devnet.rippletest.net:51233").
@@ -23,47 +23,47 @@ func main() {
defer client.Disconnect() defer client.Disconnect()
if err := client.Connect(); err != nil { if err := client.Connect(); err != nil {
fmt.Println("Error connecting to devnet:", err) fmt.Println("Error connecting to devnet:", err)
return return
} }
if !client.IsConnected() { if !client.IsConnected() {
fmt.Println("Failed to connect to devnet") fmt.Println("Failed to connect to devnet")
return return
} }
fmt.Println("Connected to devnet") fmt.Println("Connected to devnet")
fmt.Println() fmt.Println()
// Fund wallets // Fund wallets
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
// Create and fund the NFT minter wallet // Create and fund the NFT minter wallet
nftMinter, err := wallet.New(crypto.ED25519()) nftMinter, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Println("Error creating NFT minter wallet:", err) fmt.Println("Error creating NFT minter wallet:", err)
return return
} }
if err := client.FundWallet(&nftMinter); err != nil { if err := client.FundWallet(&nftMinter); err != nil {
fmt.Println("Error funding NFT minter wallet:", err) fmt.Println("Error funding NFT minter wallet:", err)
return return
} }
fmt.Println("💸 NFT minter wallet funded!") fmt.Println("NFT minter wallet funded!")
// Create and fund the NFT buyer wallet // Create and fund the NFT buyer wallet
nftBuyer, err := wallet.New(crypto.ED25519()) nftBuyer, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Println("Error creating NFT buyer wallet:", err) fmt.Println("Error creating NFT buyer wallet:", err)
return return
} }
if err := client.FundWallet(&nftBuyer); err != nil { if err := client.FundWallet(&nftBuyer); err != nil {
fmt.Println("Error funding NFT buyer wallet:", err) fmt.Println("Error funding NFT buyer wallet:", err)
return return
} }
fmt.Println("💸 NFT buyer wallet funded!") fmt.Println("NFT buyer wallet funded!")
fmt.Println() fmt.Println()
// Mint an NFT // Mint an NFT
fmt.Println("Minting NFT...") fmt.Println("Minting NFT...")
nftMint := transaction.NFTokenMint{ nftMint := transaction.NFTokenMint{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: nftMinter.ClassicAddress, Account: nftMinter.ClassicAddress,
@@ -81,34 +81,34 @@ func main() {
Wallet: &nftMinter, Wallet: &nftMinter,
}) })
if err != nil { if err != nil {
fmt.Println("Error minting NFT:", err) fmt.Println("Error minting NFT:", err)
return return
} }
if !responseMint.Validated { if !responseMint.Validated {
fmt.Println("NFTokenMint transaction is not in a validated ledger:", responseMint) fmt.Println("NFTokenMint transaction is not in a validated ledger:", responseMint)
return return
} }
fmt.Println("NFT minted successfully! - 🌎 Hash:", responseMint.Hash) fmt.Println("NFT minted successfully! - Hash:", responseMint.Hash)
fmt.Println() fmt.Println()
// Extract the NFT token offer ID from the transaction metadata // Extract the NFT token offer ID from the transaction metadata
fmt.Println("Extracting offer ID...") fmt.Println("Extracting offer ID...")
metaMap, ok := responseMint.Meta.(map[string]any) metaMap, ok := responseMint.Meta.(map[string]any)
if !ok { if !ok {
fmt.Println("Meta is not a map[string]any") fmt.Println("Meta is not a map[string]any")
return return
} }
offerID, ok := metaMap["offer_id"].(string) offerID, ok := metaMap["offer_id"].(string)
if !ok { if !ok {
fmt.Println("offer_id not found or not a string") fmt.Println("offer_id not found or not a string")
return return
} }
fmt.Println("🌎 offer_id:", offerID) fmt.Println("offer_id:", offerID)
fmt.Println() fmt.Println()
// Accept the NFT offer // Accept the NFT offer
fmt.Println("Accepting NFT offer...") fmt.Println("Accepting NFT offer...")
nftAccept := transaction.NFTokenAcceptOffer{ nftAccept := transaction.NFTokenAcceptOffer{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: nftBuyer.ClassicAddress, Account: nftBuyer.ClassicAddress,
@@ -122,12 +122,12 @@ func main() {
Wallet: &nftBuyer, Wallet: &nftBuyer,
}) })
if err != nil { if err != nil {
fmt.Println("Error accepting NFT offer:", err) fmt.Println("Error accepting NFT offer:", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("NFTokenAcceptOffer transaction is not in a validated ledger:", response) fmt.Println("NFTokenAcceptOffer transaction is not in a validated ledger:", response)
return return
} }
fmt.Println("NFT offer accepted successfully! - 🌎 Hash:", response.Hash) fmt.Println("NFT offer accepted successfully! - Hash:", response.Hash)
} }

View File

@@ -26,23 +26,23 @@ func main() {
client := rpc.NewClient(cfg) client := rpc.NewClient(cfg)
// Step 1: Fund wallets // Step 1: Fund wallets
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
// Create and fund the NFT minter wallet // Create and fund the NFT minter wallet
nftMinter, err := wallet.New(crypto.ED25519()) nftMinter, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Println("Error creating NFT minter wallet:", err) fmt.Println("Error creating NFT minter wallet:", err)
return return
} }
if err := client.FundWallet(&nftMinter); err != nil { if err := client.FundWallet(&nftMinter); err != nil {
fmt.Println("Error funding NFT minter wallet:", err) fmt.Println("Error funding NFT minter wallet:", err)
return return
} }
fmt.Println("💸 NFT minter wallet funded!") fmt.Println("NFT minter wallet funded!")
fmt.Println() fmt.Println()
// Step 2: Mint an NFT // Step 2: Mint an NFT
fmt.Println("Minting NFT...") fmt.Println("Minting NFT...")
nftMint := transaction.NFTokenMint{ nftMint := transaction.NFTokenMint{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -59,36 +59,36 @@ func main() {
Wallet: &nftMinter, Wallet: &nftMinter,
}) })
if err != nil { if err != nil {
fmt.Println("Error minting NFT:", err) fmt.Println("Error minting NFT:", err)
return return
} }
if !responseMint.Validated { if !responseMint.Validated {
fmt.Println("NFTokenMint txn is not in a validated ledger", responseMint) fmt.Println("NFTokenMint txn is not in a validated ledger", responseMint)
return return
} }
fmt.Println("NFT minted successfully! - 🌎 Hash: ", responseMint.Hash) fmt.Println("NFT minted successfully! - Hash: ", responseMint.Hash)
fmt.Println() fmt.Println()
// Step 3: Retrieve the token ID // Step 3: Retrieve the token ID
fmt.Println("Retrieving NFT ID...") fmt.Println("Retrieving NFT ID...")
metaMap, ok := responseMint.Meta.(map[string]any) metaMap, ok := responseMint.Meta.(map[string]any)
if !ok { if !ok {
fmt.Println("Meta is not a map[string]any") fmt.Println("Meta is not a map[string]any")
return return
} }
nftokenID, ok := metaMap["nftoken_id"].(string) nftokenID, ok := metaMap["nftoken_id"].(string)
if !ok { if !ok {
fmt.Println("nftoken_id not found or not a string") fmt.Println("nftoken_id not found or not a string")
return return
} }
fmt.Println("🌎 nftoken_id:", nftokenID) fmt.Println("nftoken_id:", nftokenID)
fmt.Println() fmt.Println()
// Step 4: Burn the NFT // Step 4: Burn the NFT
fmt.Println("Burn the NFT...") fmt.Println("Burn the NFT...")
nftBurn := transaction.NFTokenBurn{ nftBurn := transaction.NFTokenBurn{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -103,12 +103,12 @@ func main() {
Wallet: &nftMinter, Wallet: &nftMinter,
}) })
if err != nil { if err != nil {
fmt.Println("Error burning NFT:", err) fmt.Println("Error burning NFT:", err)
return return
} }
if !responseBurn.Validated { if !responseBurn.Validated {
fmt.Println("NFTokenBurn transactiob is not in a validated ledger", responseBurn) fmt.Println("NFTokenBurn transactiob is not in a validated ledger", responseBurn)
return return
} }
fmt.Println("NFT burned successfully! - 🌎 Hash: ", responseBurn.Hash) fmt.Println("NFT burned successfully! - Hash: ", responseBurn.Hash)
} }

View File

@@ -14,7 +14,7 @@ import (
func main() { func main() {
// Connect to the XRPL devnet // Connect to the XRPL devnet
fmt.Println("Connecting to devnet...") fmt.Println("Connecting to devnet...")
client := websocket.NewClient( client := websocket.NewClient(
websocket.NewClientConfig(). websocket.NewClientConfig().
WithHost("wss://s.devnet.rippletest.net:51233"). WithHost("wss://s.devnet.rippletest.net:51233").
@@ -23,35 +23,35 @@ func main() {
defer client.Disconnect() defer client.Disconnect()
if err := client.Connect(); err != nil { if err := client.Connect(); err != nil {
fmt.Println("Error connecting to devnet:", err) fmt.Println("Error connecting to devnet:", err)
return return
} }
if !client.IsConnected() { if !client.IsConnected() {
fmt.Println("Failed to connect to devnet") fmt.Println("Failed to connect to devnet")
return return
} }
fmt.Println("Connected to devnet") fmt.Println("Connected to devnet")
fmt.Println() fmt.Println()
// Step 1: Fund wallets // Step 1: Fund wallets
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
// Create and fund the NFT minter wallet // Create and fund the NFT minter wallet
nftMinter, err := wallet.New(crypto.ED25519()) nftMinter, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Println("Error creating NFT minter wallet:", err) fmt.Println("Error creating NFT minter wallet:", err)
return return
} }
if err := client.FundWallet(&nftMinter); err != nil { if err := client.FundWallet(&nftMinter); err != nil {
fmt.Println("Error funding NFT minter wallet:", err) fmt.Println("Error funding NFT minter wallet:", err)
return return
} }
fmt.Println("💸 NFT minter wallet funded!") fmt.Println("NFT minter wallet funded!")
fmt.Println() fmt.Println()
// Step 2: Mint an NFT // Step 2: Mint an NFT
fmt.Println("Minting NFT...") fmt.Println("Minting NFT...")
nftMint := transaction.NFTokenMint{ nftMint := transaction.NFTokenMint{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -68,36 +68,36 @@ func main() {
Wallet: &nftMinter, Wallet: &nftMinter,
}) })
if err != nil { if err != nil {
fmt.Println("Error minting NFT:", err) fmt.Println("Error minting NFT:", err)
return return
} }
if !responseMint.Validated { if !responseMint.Validated {
fmt.Println("NFTokenMint txn is not in a validated ledger", responseMint) fmt.Println("NFTokenMint txn is not in a validated ledger", responseMint)
return return
} }
fmt.Println("NFT minted successfully! - 🌎 Hash: ", responseMint.Hash) fmt.Println("NFT minted successfully! - Hash: ", responseMint.Hash)
fmt.Println() fmt.Println()
// Step 3: Retrieve the token ID // Step 3: Retrieve the token ID
fmt.Println("Retrieving NFT ID...") fmt.Println("Retrieving NFT ID...")
metaMap, ok := responseMint.Meta.(map[string]any) metaMap, ok := responseMint.Meta.(map[string]any)
if !ok { if !ok {
fmt.Println("Meta is not a map[string]any") fmt.Println("Meta is not a map[string]any")
return return
} }
nftokenID, ok := metaMap["nftoken_id"].(string) nftokenID, ok := metaMap["nftoken_id"].(string)
if !ok { if !ok {
fmt.Println("nftoken_id not found or not a string") fmt.Println("nftoken_id not found or not a string")
return return
} }
fmt.Println("🌎 nftoken_id:", nftokenID) fmt.Println("nftoken_id:", nftokenID)
fmt.Println() fmt.Println()
// Step 4: Burn the NFT // Step 4: Burn the NFT
fmt.Println("Burn the NFT...") fmt.Println("Burn the NFT...")
nftBurn := transaction.NFTokenBurn{ nftBurn := transaction.NFTokenBurn{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -112,12 +112,12 @@ func main() {
Wallet: &nftMinter, Wallet: &nftMinter,
}) })
if err != nil { if err != nil {
fmt.Println("Error burning NFT:", err) fmt.Println("Error burning NFT:", err)
return return
} }
if !responseBurn.Validated { if !responseBurn.Validated {
fmt.Println("NFTokenBurn transactiob is not in a validated ledger", responseBurn) fmt.Println("NFTokenBurn transactiob is not in a validated ledger", responseBurn)
return return
} }
fmt.Println("NFT burned successfully! - 🌎 Hash: ", responseBurn.Hash) fmt.Println("NFT burned successfully! - Hash: ", responseBurn.Hash)
} }

View File

@@ -26,22 +26,22 @@ func main() {
client := rpc.NewClient(cfg) client := rpc.NewClient(cfg)
// Step 1: Fund wallet // Step 1: Fund wallet
fmt.Println("Funding wallet...") fmt.Println("Funding wallet...")
// Create and fund the NFT minter wallet // Create and fund the NFT minter wallet
nftMinter, err := wallet.New(crypto.ED25519()) nftMinter, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Println("Error creating NFT minter wallet:", err) fmt.Println("Error creating NFT minter wallet:", err)
return return
} }
if err := client.FundWallet(&nftMinter); err != nil { if err := client.FundWallet(&nftMinter); err != nil {
fmt.Println("Error funding NFT minter wallet:", err) fmt.Println("Error funding NFT minter wallet:", err)
return return
} }
fmt.Println("💸 NFT minter wallet funded!") fmt.Println("NFT minter wallet funded!")
// Step 2: Mint two NFTs // Step 2: Mint two NFTs
fmt.Println("Minting first NFT...") fmt.Println("Minting first NFT...")
nftMint := transaction.NFTokenMint{ nftMint := transaction.NFTokenMint{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -58,37 +58,37 @@ func main() {
Wallet: &nftMinter, Wallet: &nftMinter,
}) })
if err != nil { if err != nil {
fmt.Println("Error minting first NFT:", err) fmt.Println("Error minting first NFT:", err)
return return
} }
if !responseMint.Validated { if !responseMint.Validated {
fmt.Println("First NFTokenMint transaction is not in a validated ledger", responseMint) fmt.Println("First NFTokenMint transaction is not in a validated ledger", responseMint)
return return
} }
fmt.Println("First NFT minted successfully! - 🌎 Hash: ", responseMint.Hash) fmt.Println("First NFT minted successfully! - Hash: ", responseMint.Hash)
fmt.Println() fmt.Println()
// Step 3: Retrieve the NFT token ID // Step 3: Retrieve the NFT token ID
fmt.Println("Retrieving NFT ID...") fmt.Println("Retrieving NFT ID...")
metaMap, ok := responseMint.Meta.(map[string]any) metaMap, ok := responseMint.Meta.(map[string]any)
if !ok { if !ok {
fmt.Println("Meta is not a map[string]any") fmt.Println("Meta is not a map[string]any")
return return
} }
nftokenID1, ok := metaMap["nftoken_id"].(string) nftokenID1, ok := metaMap["nftoken_id"].(string)
if !ok { if !ok {
fmt.Println("nftoken_id not found or not a string") fmt.Println("nftoken_id not found or not a string")
return return
} }
fmt.Println("🌎 nftoken_id:", nftokenID1) fmt.Println("nftoken_id:", nftokenID1)
fmt.Println() fmt.Println()
// ------ // ------
fmt.Println("Minting second NFT...") fmt.Println("Minting second NFT...")
nftMint2 := transaction.NFTokenMint{ nftMint2 := transaction.NFTokenMint{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -105,36 +105,36 @@ func main() {
Wallet: &nftMinter, Wallet: &nftMinter,
}) })
if err != nil { if err != nil {
fmt.Println("Error minting second NFT:", err) fmt.Println("Error minting second NFT:", err)
return return
} }
if !responseMint.Validated { if !responseMint.Validated {
fmt.Println("Second NFTokenMint transaction is not in a validated ledger", responseMint) fmt.Println("Second NFTokenMint transaction is not in a validated ledger", responseMint)
return return
} }
fmt.Println("Second NFT minted successfully! - 🌎 Hash: ", responseMint.Hash) fmt.Println("Second NFT minted successfully! - Hash: ", responseMint.Hash)
fmt.Println() fmt.Println()
// Step 3: Retrieve the second NFT token ID // Step 3: Retrieve the second NFT token ID
fmt.Println("Retrieving second NFT ID...") fmt.Println("Retrieving second NFT ID...")
metaMap2, ok := responseMint2.Meta.(map[string]any) metaMap2, ok := responseMint2.Meta.(map[string]any)
if !ok { if !ok {
fmt.Println("Meta is not a map[string]any") fmt.Println("Meta is not a map[string]any")
return return
} }
nftokenID2, ok := metaMap2["nftoken_id"].(string) nftokenID2, ok := metaMap2["nftoken_id"].(string)
if !ok { if !ok {
fmt.Println("nftoken_id not found or not a string") fmt.Println("nftoken_id not found or not a string")
return return
} }
fmt.Println("🌎 nftoken_id:", nftokenID2) fmt.Println("nftoken_id:", nftokenID2)
fmt.Println() fmt.Println()
// Step 4: Cancel the NFT offers // Step 4: Cancel the NFT offers
fmt.Println("Canceling NFT offers...") fmt.Println("Canceling NFT offers...")
nftCancel := transaction.NFTokenCancelOffer{ nftCancel := transaction.NFTokenCancelOffer{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -152,12 +152,12 @@ func main() {
Wallet: &nftMinter, Wallet: &nftMinter,
}) })
if err != nil { if err != nil {
fmt.Println("Error canceling NFT offers:", err) fmt.Println("Error canceling NFT offers:", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("NFTokenCancelOffer transaction is not in a validated ledger", response) fmt.Println("NFTokenCancelOffer transaction is not in a validated ledger", response)
return return
} }
fmt.Println("NFT offers canceled successfully! - 🌎 Hash: ", response.Hash) fmt.Println("NFT offers canceled successfully! - Hash: ", response.Hash)
} }

View File

@@ -14,7 +14,7 @@ import (
func main() { func main() {
// Connect to the XRPL devnet // Connect to the XRPL devnet
fmt.Println("Connecting to devnet...") fmt.Println("Connecting to devnet...")
client := websocket.NewClient( client := websocket.NewClient(
websocket.NewClientConfig(). websocket.NewClientConfig().
WithHost("wss://s.devnet.rippletest.net:51233"). WithHost("wss://s.devnet.rippletest.net:51233").
@@ -23,34 +23,34 @@ func main() {
defer client.Disconnect() defer client.Disconnect()
if err := client.Connect(); err != nil { if err := client.Connect(); err != nil {
fmt.Println("Error connecting to devnet:", err) fmt.Println("Error connecting to devnet:", err)
return return
} }
if !client.IsConnected() { if !client.IsConnected() {
fmt.Println("Failed to connect to devnet") fmt.Println("Failed to connect to devnet")
return return
} }
fmt.Println("Connected to devnet") fmt.Println("Connected to devnet")
fmt.Println() fmt.Println()
// Step 1: Fund wallet // Step 1: Fund wallet
fmt.Println("Funding wallet...") fmt.Println("Funding wallet...")
// Create and fund the NFT minter wallet // Create and fund the NFT minter wallet
nftMinter, err := wallet.New(crypto.ED25519()) nftMinter, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Println("Error creating NFT minter wallet:", err) fmt.Println("Error creating NFT minter wallet:", err)
return return
} }
if err := client.FundWallet(&nftMinter); err != nil { if err := client.FundWallet(&nftMinter); err != nil {
fmt.Println("Error funding NFT minter wallet:", err) fmt.Println("Error funding NFT minter wallet:", err)
return return
} }
fmt.Println("💸 NFT minter wallet funded!") fmt.Println("NFT minter wallet funded!")
// Step 2: Mint two NFTs // Step 2: Mint two NFTs
fmt.Println("Minting first NFT...") fmt.Println("Minting first NFT...")
nftMint := transaction.NFTokenMint{ nftMint := transaction.NFTokenMint{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -67,37 +67,37 @@ func main() {
Wallet: &nftMinter, Wallet: &nftMinter,
}) })
if err != nil { if err != nil {
fmt.Println("Error minting first NFT:", err) fmt.Println("Error minting first NFT:", err)
return return
} }
if !responseMint.Validated { if !responseMint.Validated {
fmt.Println("First NFTokenMint transaction is not in a validated ledger", responseMint) fmt.Println("First NFTokenMint transaction is not in a validated ledger", responseMint)
return return
} }
fmt.Println("First NFT minted successfully! - 🌎 Hash: ", responseMint.Hash) fmt.Println("First NFT minted successfully! - Hash: ", responseMint.Hash)
fmt.Println() fmt.Println()
// Step 3: Retrieve the NFT token ID // Step 3: Retrieve the NFT token ID
fmt.Println("Retrieving NFT ID...") fmt.Println("Retrieving NFT ID...")
metaMap, ok := responseMint.Meta.(map[string]any) metaMap, ok := responseMint.Meta.(map[string]any)
if !ok { if !ok {
fmt.Println("Meta is not a map[string]any") fmt.Println("Meta is not a map[string]any")
return return
} }
nftokenID1, ok := metaMap["nftoken_id"].(string) nftokenID1, ok := metaMap["nftoken_id"].(string)
if !ok { if !ok {
fmt.Println("nftoken_id not found or not a string") fmt.Println("nftoken_id not found or not a string")
return return
} }
fmt.Println("🌎 nftoken_id:", nftokenID1) fmt.Println("nftoken_id:", nftokenID1)
fmt.Println() fmt.Println()
// ------ // ------
fmt.Println("Minting second NFT...") fmt.Println("Minting second NFT...")
nftMint2 := transaction.NFTokenMint{ nftMint2 := transaction.NFTokenMint{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -114,36 +114,36 @@ func main() {
Wallet: &nftMinter, Wallet: &nftMinter,
}) })
if err != nil { if err != nil {
fmt.Println("Error minting second NFT:", err) fmt.Println("Error minting second NFT:", err)
return return
} }
if !responseMint.Validated { if !responseMint.Validated {
fmt.Println("Second NFTokenMint transaction is not in a validated ledger", responseMint) fmt.Println("Second NFTokenMint transaction is not in a validated ledger", responseMint)
return return
} }
fmt.Println("Second NFT minted successfully! - 🌎 Hash: ", responseMint.Hash) fmt.Println("Second NFT minted successfully! - Hash: ", responseMint.Hash)
fmt.Println() fmt.Println()
// Step 3: Retrieve the second NFT token ID // Step 3: Retrieve the second NFT token ID
fmt.Println("Retrieving second NFT ID...") fmt.Println("Retrieving second NFT ID...")
metaMap2, ok := responseMint2.Meta.(map[string]any) metaMap2, ok := responseMint2.Meta.(map[string]any)
if !ok { if !ok {
fmt.Println("Meta is not a map[string]any") fmt.Println("Meta is not a map[string]any")
return return
} }
nftokenID2, ok := metaMap2["nftoken_id"].(string) nftokenID2, ok := metaMap2["nftoken_id"].(string)
if !ok { if !ok {
fmt.Println("nftoken_id not found or not a string") fmt.Println("nftoken_id not found or not a string")
return return
} }
fmt.Println("🌎 nftoken_id:", nftokenID2) fmt.Println("nftoken_id:", nftokenID2)
fmt.Println() fmt.Println()
// Step 4: Cancel the NFT offers // Step 4: Cancel the NFT offers
fmt.Println("Canceling NFT offers...") fmt.Println("Canceling NFT offers...")
nftCancel := transaction.NFTokenCancelOffer{ nftCancel := transaction.NFTokenCancelOffer{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
@@ -161,12 +161,12 @@ func main() {
Wallet: &nftMinter, Wallet: &nftMinter,
}) })
if err != nil { if err != nil {
fmt.Println("Error canceling NFT offers:", err) fmt.Println("Error canceling NFT offers:", err)
return return
} }
if !response.Validated { if !response.Validated {
fmt.Println("NFTokenCancelOffer transaction is not in a validated ledger", response) fmt.Println("NFTokenCancelOffer transaction is not in a validated ledger", response)
return return
} }
fmt.Println("NFT offers canceled successfully! - 🌎 Hash: ", response.Hash) fmt.Println("NFT offers canceled successfully! - Hash: ", response.Hash)
} }

View File

@@ -24,19 +24,19 @@ func main() {
client := rpc.NewClient(cfg) client := rpc.NewClient(cfg)
fmt.Println() fmt.Println()
fmt.Println("Funding wallet...") fmt.Println("Funding wallet...")
// Create and fund the nft wallet // Create and fund the nft wallet
nftWallet, err := wallet.New(crypto.ED25519()) nftWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Println("Error creating nft wallet:", err) fmt.Println("Error creating nft wallet:", err)
return return
} }
if err := client.FundWallet(&nftWallet); err != nil { if err := client.FundWallet(&nftWallet); err != nil {
fmt.Println("Error funding nft wallet:", err) fmt.Println("Error funding nft wallet:", err)
return return
} }
fmt.Println("💸 NFT wallet funded! - #️⃣: ", nftWallet.ClassicAddress) fmt.Println("NFT wallet funded: ", nftWallet.ClassicAddress)
fmt.Println() fmt.Println()
// Mint NFT // Mint NFT
@@ -56,29 +56,29 @@ func main() {
Wallet: &nftWallet, Wallet: &nftWallet,
}) })
if err != nil { if err != nil {
fmt.Println("Error minting NFT:", err) fmt.Println("Error minting NFT:", err)
return return
} }
if !responseMint.Validated { if !responseMint.Validated {
fmt.Println("NFTokenMint txn is not in a validated ledger", responseMint) fmt.Println("NFTokenMint txn is not in a validated ledger", responseMint)
return return
} }
fmt.Println("NFT minted successfully! - 🌎 Hash: ", responseMint.Hash) fmt.Println("NFT minted successfully! - Hash: ", responseMint.Hash)
fmt.Println() fmt.Println()
metaMap, ok := responseMint.Meta.(map[string]any) metaMap, ok := responseMint.Meta.(map[string]any)
if !ok { if !ok {
fmt.Println("Meta is not a map[string]any") fmt.Println("Meta is not a map[string]any")
return return
} }
nftokenID, ok := metaMap["nftoken_id"].(string) nftokenID, ok := metaMap["nftoken_id"].(string)
if !ok { if !ok {
fmt.Println("nftoken_id not found or not a string") fmt.Println("nftoken_id not found or not a string")
return return
} }
fmt.Println("🌎 nftoken_id:", nftokenID) fmt.Println("nftoken_id:", nftokenID)
fmt.Println() fmt.Println()
// Update NFT // Update NFT
@@ -96,12 +96,12 @@ func main() {
Wallet: &nftWallet, Wallet: &nftWallet,
}) })
if err != nil { if err != nil {
fmt.Println("Error modifying NFT:", err) fmt.Println("Error modifying NFT:", err)
return return
} }
if !responseModify.Validated { if !responseModify.Validated {
fmt.Println("NFTokenModify txn is not in a validated ledger", responseModify) fmt.Println("NFTokenModify txn is not in a validated ledger", responseModify)
return return
} }
fmt.Println("NFT URI modified successfully! - 🌎 Hash: ", responseModify.Hash) fmt.Println("NFT URI modified successfully! - Hash: ", responseModify.Hash)
} }

View File

@@ -13,7 +13,7 @@ import (
) )
func main() { func main() {
fmt.Println("Connecting to devnet...") fmt.Println("Connecting to devnet...")
client := websocket.NewClient( client := websocket.NewClient(
websocket.NewClientConfig(). websocket.NewClientConfig().
WithHost("wss://s.devnet.rippletest.net:51233"). WithHost("wss://s.devnet.rippletest.net:51233").
@@ -28,25 +28,25 @@ func main() {
} }
if !client.IsConnected() { if !client.IsConnected() {
fmt.Println("Failed to connect to devnet") fmt.Println("Failed to connect to devnet")
return return
} }
fmt.Println("Connected to devnet") fmt.Println("Connected to devnet")
fmt.Println() fmt.Println()
// Create and fund the nft wallet // Create and fund the nft wallet
fmt.Println("Funding wallet...") fmt.Println("Funding wallet...")
nftWallet, err := wallet.New(crypto.ED25519()) nftWallet, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Println("Error creating nft wallet:", err) fmt.Println("Error creating nft wallet:", err)
return return
} }
if err := client.FundWallet(&nftWallet); err != nil { if err := client.FundWallet(&nftWallet); err != nil {
fmt.Println("Error funding nft wallet:", err) fmt.Println("Error funding nft wallet:", err)
return return
} }
fmt.Println("💸 NFT wallet funded!") fmt.Println("NFT wallet funded!")
fmt.Println() fmt.Println()
// Mint NFT // Mint NFT
@@ -66,29 +66,29 @@ func main() {
Wallet: &nftWallet, Wallet: &nftWallet,
}) })
if err != nil { if err != nil {
fmt.Println("Error minting NFT:", err) fmt.Println("Error minting NFT:", err)
return return
} }
if !responseMint.Validated { if !responseMint.Validated {
fmt.Println("NFTokenMint txn is not in a validated ledger", responseMint) fmt.Println("NFTokenMint txn is not in a validated ledger", responseMint)
return return
} }
fmt.Println("NFT minted successfully! - 🌎 Hash: ", responseMint.Hash) fmt.Println("NFT minted successfully! - Hash: ", responseMint.Hash)
fmt.Println() fmt.Println()
metaMap, ok := responseMint.Meta.(map[string]any) metaMap, ok := responseMint.Meta.(map[string]any)
if !ok { if !ok {
fmt.Println("Meta is not a map[string]any") fmt.Println("Meta is not a map[string]any")
return return
} }
nftokenID, ok := metaMap["nftoken_id"].(string) nftokenID, ok := metaMap["nftoken_id"].(string)
if !ok { if !ok {
fmt.Println("nftoken_id not found or not a string") fmt.Println("nftoken_id not found or not a string")
return return
} }
fmt.Println("🌎 nftoken_id:", nftokenID) fmt.Println("nftoken_id:", nftokenID)
fmt.Println() fmt.Println()
// Update NFT // Update NFT
@@ -106,12 +106,12 @@ func main() {
Wallet: &nftWallet, Wallet: &nftWallet,
}) })
if err != nil { if err != nil {
fmt.Println("Error modifying NFT:", err) fmt.Println("Error modifying NFT:", err)
return return
} }
if !responseModify.Validated { if !responseModify.Validated {
fmt.Println("NFTokenModify txn is not in a validated ledger", responseModify) fmt.Println("NFTokenModify txn is not in a validated ledger", responseModify)
return return
} }
fmt.Println("NFT URI modified successfully! - 🌎 Hash: ", responseModify.Hash) fmt.Println("NFT URI modified successfully! - Hash: ", responseModify.Hash)
} }

View File

@@ -23,7 +23,7 @@ func main() {
client := rpc.NewClient(cfg) client := rpc.NewClient(cfg)
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
w1, err := wallet.New(crypto.ED25519()) w1, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@@ -40,18 +40,18 @@ func main() {
return return
} }
fmt.Println("💸 Wallet 1 funded") fmt.Println("Wallet 1 funded")
if err := client.FundWallet(&w2); err != nil { if err := client.FundWallet(&w2); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet 2 funded") fmt.Println("Wallet 2 funded")
fmt.Println() fmt.Println()
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
fmt.Println("Sending TrustSet transaction...") fmt.Println("Sending TrustSet transaction...")
ts := &transaction.TrustSet{ ts := &transaction.TrustSet{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w2.ClassicAddress, Account: w2.ClassicAddress,
@@ -83,12 +83,12 @@ func main() {
return return
} }
fmt.Println("TrustSet transaction submitted!") fmt.Println("TrustSet transaction submitted!")
fmt.Printf("🌐 Hash: %s\n", res.Hash.String()) fmt.Printf("Hash: %s\n", res.Hash.String())
fmt.Printf("🌐 Validated: %t\n", res.Validated) fmt.Printf("Validated: %t\n", res.Validated)
fmt.Println() fmt.Println()
fmt.Println("Issuing tokens for wallet 2...") fmt.Println("Issuing tokens for wallet 2...")
p := &transaction.Payment{ p := &transaction.Payment{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w1.GetAddress(), Account: w1.GetAddress(),
@@ -121,12 +121,12 @@ func main() {
return return
} }
fmt.Println("Payment transaction submitted!") fmt.Println("Payment transaction submitted!")
fmt.Printf("🌐 Hash: %s\n", res.Hash.String()) fmt.Printf("Hash: %s\n", res.Hash.String())
fmt.Printf("🌐 Validated: %t\n", res.Validated) fmt.Printf("Validated: %t\n", res.Validated)
fmt.Println() fmt.Println()
fmt.Println("Submitting Partial Payment transaction...") fmt.Println("Submitting Partial Payment transaction...")
pp := &transaction.Payment{ pp := &transaction.Payment{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w2.GetAddress(), Account: w2.GetAddress(),
@@ -161,8 +161,8 @@ func main() {
return return
} }
fmt.Println("Partial Payment transaction submitted!") fmt.Println("Partial Payment transaction submitted!")
fmt.Printf("🌐 Hash: %s\n", res.Hash.String()) fmt.Printf("Hash: %s\n", res.Hash.String())
fmt.Printf("🌐 Validated: %t\n", res.Validated) fmt.Printf("Validated: %t\n", res.Validated)
fmt.Println() fmt.Println()
} }

View File

@@ -13,7 +13,7 @@ import (
) )
func main() { func main() {
fmt.Println("Connecting to testnet...") fmt.Println("Connecting to testnet...")
client := websocket.NewClient( client := websocket.NewClient(
websocket.NewClientConfig(). websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233"). WithHost("wss://s.altnet.rippletest.net:51233").
@@ -27,14 +27,14 @@ func main() {
} }
if !client.IsConnected() { if !client.IsConnected() {
fmt.Println("Failed to connect to testnet") fmt.Println("Failed to connect to testnet")
return return
} }
fmt.Println("Connected to testnet") fmt.Println("Connected to testnet")
fmt.Println() fmt.Println()
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
w1, err := wallet.New(crypto.ED25519()) w1, err := wallet.New(crypto.ED25519())
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@@ -51,18 +51,18 @@ func main() {
return return
} }
fmt.Println("💸 Wallet 1 funded") fmt.Println("Wallet 1 funded")
if err := client.FundWallet(&w2); err != nil { if err := client.FundWallet(&w2); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet 2 funded") fmt.Println("Wallet 2 funded")
fmt.Println() fmt.Println()
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
fmt.Println("Sending TrustSet transaction...") fmt.Println("Sending TrustSet transaction...")
ts := &transaction.TrustSet{ ts := &transaction.TrustSet{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w2.ClassicAddress, Account: w2.ClassicAddress,
@@ -94,12 +94,12 @@ func main() {
return return
} }
fmt.Println("TrustSet transaction submitted!") fmt.Println("TrustSet transaction submitted!")
fmt.Printf("🌐 Hash: %s\n", res.Hash.String()) fmt.Printf("Hash: %s\n", res.Hash.String())
fmt.Printf("🌐 Validated: %t\n", res.Validated) fmt.Printf("Validated: %t\n", res.Validated)
fmt.Println() fmt.Println()
fmt.Println("Issuing tokens for wallet 2...") fmt.Println("Issuing tokens for wallet 2...")
p := &transaction.Payment{ p := &transaction.Payment{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w1.GetAddress(), Account: w1.GetAddress(),
@@ -132,12 +132,12 @@ func main() {
return return
} }
fmt.Println("Payment transaction submitted!") fmt.Println("Payment transaction submitted!")
fmt.Printf("🌐 Hash: %s\n", res.Hash.String()) fmt.Printf("Hash: %s\n", res.Hash.String())
fmt.Printf("🌐 Validated: %t\n", res.Validated) fmt.Printf("Validated: %t\n", res.Validated)
fmt.Println() fmt.Println()
fmt.Println("Submitting Partial Payment transaction...") fmt.Println("Submitting Partial Payment transaction...")
pp := &transaction.Payment{ pp := &transaction.Payment{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w2.GetAddress(), Account: w2.GetAddress(),
@@ -172,8 +172,8 @@ func main() {
return return
} }
fmt.Println("Partial Payment transaction submitted!") fmt.Println("Partial Payment transaction submitted!")
fmt.Printf("🌐 Hash: %s\n", res.Hash.String()) fmt.Printf("Hash: %s\n", res.Hash.String())
fmt.Printf("🌐 Validated: %t\n", res.Validated) fmt.Printf("Validated: %t\n", res.Validated)
fmt.Println() fmt.Println()
} }

View File

@@ -43,16 +43,16 @@ func main() {
return return
} }
fmt.Println("Funding wallet...") fmt.Println("Funding wallet...")
if err := client.FundWallet(&wallet); err != nil { if err := client.FundWallet(&wallet); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet funded") fmt.Println("Wallet funded")
fmt.Println() fmt.Println()
fmt.Println("Getting paths...") fmt.Println("Getting paths...")
res, err := client.GetRipplePathFind(&path.RipplePathFindRequest{ res, err := client.GetRipplePathFind(&path.RipplePathFindRequest{
SourceAccount: wallet.GetAddress(), SourceAccount: wallet.GetAddress(),
SourceCurrencies: []pathtypes.RipplePathFindCurrency{ SourceCurrencies: []pathtypes.RipplePathFindCurrency{
@@ -68,15 +68,15 @@ func main() {
return return
} }
fmt.Printf("🌐 Computed paths: %d\n", len(res.Alternatives)) fmt.Printf("Computed paths: %d\n", len(res.Alternatives))
fmt.Println() fmt.Println()
if len(res.Alternatives) == 0 { if len(res.Alternatives) == 0 {
fmt.Println("No alternatives found") fmt.Println("No alternatives found")
return return
} }
fmt.Println("Submitting Payment through path: ", res.Alternatives[0].PathsComputed) fmt.Println("Submitting Payment through path: ", res.Alternatives[0].PathsComputed)
p := &transaction.Payment{ p := &transaction.Payment{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: wallet.GetAddress(), Account: wallet.GetAddress(),
@@ -105,7 +105,7 @@ func main() {
return return
} }
fmt.Println("Payment submitted") fmt.Println("Payment submitted")
fmt.Printf("🌐 Hash: %s\n", hash) fmt.Printf("Hash: %s\n", hash)
fmt.Printf("🌐 Validated: %t\n", txRes.Validated) fmt.Printf("Validated: %t\n", txRes.Validated)
} }

View File

@@ -27,7 +27,7 @@ var (
) )
func main() { func main() {
fmt.Println("Connecting to testnet...") fmt.Println("Connecting to testnet...")
client := websocket.NewClient( client := websocket.NewClient(
websocket.NewClientConfig(). websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233"). WithHost("wss://s.altnet.rippletest.net:51233").
@@ -41,11 +41,11 @@ func main() {
} }
if !client.IsConnected() { if !client.IsConnected() {
fmt.Println("Failed to connect to testnet") fmt.Println("Failed to connect to testnet")
return return
} }
fmt.Println("Connected to testnet") fmt.Println("Connected to testnet")
fmt.Println() fmt.Println()
wallet, err := wallet.New(crypto.ED25519()) wallet, err := wallet.New(crypto.ED25519())
@@ -54,16 +54,16 @@ func main() {
return return
} }
fmt.Println("Funding wallet...") fmt.Println("Funding wallet...")
if err := client.FundWallet(&wallet); err != nil { if err := client.FundWallet(&wallet); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet funded") fmt.Println("Wallet funded")
fmt.Println() fmt.Println()
fmt.Println("Getting paths...") fmt.Println("Getting paths...")
res, err := client.GetRipplePathFind(&path.RipplePathFindRequest{ res, err := client.GetRipplePathFind(&path.RipplePathFindRequest{
SourceAccount: wallet.GetAddress(), SourceAccount: wallet.GetAddress(),
SourceCurrencies: []pathtypes.RipplePathFindCurrency{ SourceCurrencies: []pathtypes.RipplePathFindCurrency{
@@ -79,15 +79,15 @@ func main() {
return return
} }
fmt.Printf("🌐 Computed paths: %d\n", len(res.Alternatives)) fmt.Printf("Computed paths: %d\n", len(res.Alternatives))
fmt.Println() fmt.Println()
if len(res.Alternatives) == 0 { if len(res.Alternatives) == 0 {
fmt.Println("No alternatives found") fmt.Println("No alternatives found")
return return
} }
fmt.Println("Submitting Payment through path: ", res.Alternatives[0].PathsComputed) fmt.Println("Submitting Payment through path: ", res.Alternatives[0].PathsComputed)
p := &transaction.Payment{ p := &transaction.Payment{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: wallet.GetAddress(), Account: wallet.GetAddress(),
@@ -116,7 +116,7 @@ func main() {
return return
} }
fmt.Println("Payment submitted") fmt.Println("Payment submitted")
fmt.Printf("🌐 Hash: %s\n", hash) fmt.Printf("Hash: %s\n", hash)
fmt.Printf("🌐 Validated: %t\n", txRes.Validated) fmt.Printf("Validated: %t\n", txRes.Validated)
} }

View File

@@ -39,18 +39,18 @@ func main() {
balance, err := client.GetXrpBalance(w.GetAddress()) balance, err := client.GetXrpBalance(w.GetAddress())
if err != nil || balance == "0" { if err != nil || balance == "0" {
fmt.Println("Funding wallet...") fmt.Println("Funding wallet...")
err = client.FundWallet(&w) err = client.FundWallet(&w)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet funded") fmt.Println("Wallet funded")
} }
balance, _ = client.GetXrpBalance(w.GetAddress()) balance, _ = client.GetXrpBalance(w.GetAddress())
fmt.Printf("💸 Balance: %s\n", balance) fmt.Printf("Balance: %s\n", balance)
amount, err := currency.XrpToDrops("1") amount, err := currency.XrpToDrops("1")
if err != nil { if err != nil {
@@ -64,7 +64,7 @@ func main() {
return return
} }
fmt.Println("Sending payment...") fmt.Println("Sending payment...")
payment := transactions.Payment{ payment := transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(w.GetAddress()), Account: types.Address(w.GetAddress()),
@@ -109,7 +109,7 @@ func main() {
return return
} }
fmt.Println("Payment submitted") fmt.Println("Payment submitted")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Printf("🌐 Validated: %t\n", response.Validated) fmt.Printf("Validated: %t\n", response.Validated)
} }

View File

@@ -33,30 +33,30 @@ func main() {
) )
defer client.Disconnect() defer client.Disconnect()
fmt.Println("Connecting to server...") fmt.Println("Connecting to server...")
if err := client.Connect(); err != nil { if err := client.Connect(); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("Connected to server") fmt.Println("Connected to server")
fmt.Println() fmt.Println()
balance, err := client.GetXrpBalance(w.GetAddress()) balance, err := client.GetXrpBalance(w.GetAddress())
if err != nil || balance == "0" { if err != nil || balance == "0" {
fmt.Println("Funding wallet...") fmt.Println("Funding wallet...")
err = client.FundWallet(&w) err = client.FundWallet(&w)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet funded") fmt.Println("Wallet funded")
} }
balance, _ = client.GetXrpBalance(w.GetAddress()) balance, _ = client.GetXrpBalance(w.GetAddress())
fmt.Printf("💸 Balance: %s\n", balance) fmt.Printf("Balance: %s\n", balance)
amount, err := currency.XrpToDrops("1") amount, err := currency.XrpToDrops("1")
if err != nil { if err != nil {
@@ -70,7 +70,7 @@ func main() {
return return
} }
fmt.Println("Sending payment...") fmt.Println("Sending payment...")
payment := transactions.Payment{ payment := transactions.Payment{
BaseTx: transactions.BaseTx{ BaseTx: transactions.BaseTx{
Account: types.Address(w.GetAddress()), Account: types.Address(w.GetAddress()),
@@ -115,7 +115,7 @@ func main() {
return return
} }
fmt.Println("Payment submitted") fmt.Println("Payment submitted")
fmt.Printf("🌐 Hash: %s\n", response.Hash.String()) fmt.Printf("Hash: %s\n", response.Hash.String())
fmt.Printf("🌐 Validated: %t\n", response.Validated) fmt.Printf("Validated: %t\n", response.Validated)
} }

View File

@@ -38,13 +38,13 @@ func main() {
return return
} }
fmt.Println("Funding wallet...") fmt.Println("Funding wallet...")
if err := client.FundWallet(&w); err != nil { if err := client.FundWallet(&w); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet funded") fmt.Println("Wallet funded")
fmt.Println() fmt.Println()
xrpAmount, err := currency.XrpToDrops("1") xrpAmount, err := currency.XrpToDrops("1")
@@ -59,7 +59,7 @@ func main() {
return return
} }
fmt.Println("Sending 1 XRP to rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe...") fmt.Println("Sending 1 XRP to rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe...")
p := &transaction.Payment{ p := &transaction.Payment{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: types.Address(w.GetAddress()), Account: types.Address(w.GetAddress()),
@@ -88,11 +88,11 @@ func main() {
return return
} }
fmt.Println("Payment submitted") fmt.Println("Payment submitted")
fmt.Printf("🌐 Hash: %s\n", res.Hash) fmt.Printf("Hash: %s\n", res.Hash)
fmt.Printf("🌐 Validated: %t\n", res.Validated) fmt.Printf("Validated: %t\n", res.Validated)
fmt.Println() fmt.Println()
fmt.Println("Using SubmitTxAndWait with wallet") fmt.Println("Using SubmitTxAndWait with wallet")
fmt.Println() fmt.Println()
flattenedTx2 := p.Flatten() flattenedTx2 := p.Flatten()
@@ -105,7 +105,7 @@ func main() {
return return
} }
fmt.Println("Payment submitted via SubmitTxAndWait") fmt.Println("Payment submitted via SubmitTxAndWait")
fmt.Printf("🌐 Hash: %s\n", resp.Hash) fmt.Printf("Hash: %s\n", resp.Hash)
fmt.Printf("🌐 Validated: %t\n", resp.Validated) fmt.Printf("Validated: %t\n", resp.Validated)
} }

View File

@@ -28,11 +28,11 @@ if err := client.Connect(); err != nil {
} }
if !client.IsConnected() { if !client.IsConnected() {
fmt.Println("Failed to connect to testnet") fmt.Println("Failed to connect to testnet")
return return
} }
fmt.Println("Connected to testnet") fmt.Println("Connected to testnet")
fmt.Println() fmt.Println()
// Example credentials // Example credentials
@@ -44,13 +44,13 @@ if err != nil {
} }
// Funding the wallet // Funding the wallet
fmt.Println("Funding wallet...") fmt.Println("Funding wallet...")
if err := client.FundWallet(&w); err != nil { if err := client.FundWallet(&w); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet funded") fmt.Println("Wallet funded")
fmt.Println() fmt.Println()
xrpAmount, err := currency.XrpToDrops("1") xrpAmount, err := currency.XrpToDrops("1")
@@ -110,10 +110,10 @@ if err != nil {
// SubmitTxBlobAndWait() handles this automatically, but it can take 4-7s. // SubmitTxBlobAndWait() handles this automatically, but it can take 4-7s.
// Check transaction results ------------------------------------------------- // Check transaction results -------------------------------------------------
fmt.Printf("🌐 Hash: %s\n", res_blob.Hash) fmt.Printf("Hash: %s\n", res_blob.Hash)
fmt.Printf("🌐 Meta: %t\n", res_blob.Meta) fmt.Printf("Meta: %t\n", res_blob.Meta)
res, _ := client.Request(&transactions.TxRequest{ res, _ := client.Request(&transactions.TxRequest{
Transaction: res_flat.Hash.String(), Transaction: res_flat.Hash.String(),
}) })
fmt.Printf("🌐 Result: %s\n", res.Result) fmt.Printf("Result: %s\n", res.Result)
} }

View File

@@ -40,30 +40,30 @@ func main() {
return return
} }
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
if err := client.FundWallet(&w1); err != nil { if err := client.FundWallet(&w1); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet 1 funded") fmt.Println("Wallet 1 funded")
if err := client.FundWallet(&w2); err != nil { if err := client.FundWallet(&w2); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet 2 funded") fmt.Println("Wallet 2 funded")
if err := client.FundWallet(&regularKeyWallet); err != nil { if err := client.FundWallet(&regularKeyWallet); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Regular key wallet funded") fmt.Println("Regular key wallet funded")
fmt.Println() fmt.Println()
fmt.Println("Setting regular key...") fmt.Println("Setting regular key...")
rk := &transaction.SetRegularKey{ rk := &transaction.SetRegularKey{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w1.GetAddress(), Account: w1.GetAddress(),
@@ -91,12 +91,12 @@ func main() {
return return
} }
fmt.Println("SetRegularKey transaction submitted") fmt.Println("SetRegularKey transaction submitted")
fmt.Printf("🌐 Hash: %s\n", res.Hash) fmt.Printf("Hash: %s\n", res.Hash)
fmt.Printf("🌐 Validated: %t\n", res.Validated) fmt.Printf("Validated: %t\n", res.Validated)
fmt.Println() fmt.Println()
fmt.Println("Checking if regular key is set...") fmt.Println("Checking if regular key is set...")
p := &transaction.Payment{ p := &transaction.Payment{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w1.GetAddress(), Account: w1.GetAddress(),
@@ -125,7 +125,7 @@ func main() {
return return
} }
fmt.Println("Payment transaction submitted") fmt.Println("Payment transaction submitted")
fmt.Printf("🌐 Hash: %s\n", res.Hash) fmt.Printf("Hash: %s\n", res.Hash)
fmt.Printf("🌐 Validated: %t\n", res.Validated) fmt.Printf("Validated: %t\n", res.Validated)
} }

View File

@@ -12,7 +12,7 @@ import (
) )
func main() { func main() {
fmt.Println("Connecting to testnet...") fmt.Println("Connecting to testnet...")
client := websocket.NewClient( client := websocket.NewClient(
websocket.NewClientConfig(). websocket.NewClientConfig().
WithHost("wss://s.altnet.rippletest.net:51233"). WithHost("wss://s.altnet.rippletest.net:51233").
@@ -26,11 +26,11 @@ func main() {
} }
if !client.IsConnected() { if !client.IsConnected() {
fmt.Println("Failed to connect to testnet") fmt.Println("Failed to connect to testnet")
return return
} }
fmt.Println("Connected to testnet") fmt.Println("Connected to testnet")
fmt.Println() fmt.Println()
w1, err := wallet.New(crypto.ED25519()) w1, err := wallet.New(crypto.ED25519())
@@ -51,30 +51,30 @@ func main() {
return return
} }
fmt.Println("Funding wallets...") fmt.Println("Funding wallets...")
if err := client.FundWallet(&w1); err != nil { if err := client.FundWallet(&w1); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet 1 funded") fmt.Println("Wallet 1 funded")
if err := client.FundWallet(&w2); err != nil { if err := client.FundWallet(&w2); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet 2 funded") fmt.Println("Wallet 2 funded")
if err := client.FundWallet(&regularKeyWallet); err != nil { if err := client.FundWallet(&regularKeyWallet); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Regular key wallet funded") fmt.Println("Regular key wallet funded")
fmt.Println() fmt.Println()
fmt.Println("Setting regular key...") fmt.Println("Setting regular key...")
rk := &transaction.SetRegularKey{ rk := &transaction.SetRegularKey{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w1.GetAddress(), Account: w1.GetAddress(),
@@ -102,12 +102,12 @@ func main() {
return return
} }
fmt.Println("SetRegularKey transaction submitted") fmt.Println("SetRegularKey transaction submitted")
fmt.Printf("🌐 Hash: %s\n", res.Hash) fmt.Printf("Hash: %s\n", res.Hash)
fmt.Printf("🌐 Validated: %t\n", res.Validated) fmt.Printf("Validated: %t\n", res.Validated)
fmt.Println() fmt.Println()
fmt.Println("Checking if regular key is set...") fmt.Println("Checking if regular key is set...")
p := &transaction.Payment{ p := &transaction.Payment{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w1.GetAddress(), Account: w1.GetAddress(),
@@ -136,7 +136,7 @@ func main() {
return return
} }
fmt.Println("Payment transaction submitted") fmt.Println("Payment transaction submitted")
fmt.Printf("🌐 Hash: %s\n", res.Hash) fmt.Printf("Hash: %s\n", res.Hash)
fmt.Printf("🌐 Validated: %t\n", res.Validated) fmt.Printf("Validated: %t\n", res.Validated)
} }

View File

@@ -29,13 +29,13 @@ func main() {
return return
} }
fmt.Println("Funding wallet...") fmt.Println("Funding wallet...")
if err := client.FundWallet(&w); err != nil { if err := client.FundWallet(&w); err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
fmt.Println("💸 Wallet funded") fmt.Println("Wallet funded")
fmt.Println() fmt.Println()
info, err := client.GetAccountInfo(&account.InfoRequest{ info, err := client.GetAccountInfo(&account.InfoRequest{
@@ -46,10 +46,10 @@ func main() {
return return
} }
fmt.Println("🌐 Current wallet sequence:", info.AccountData.Sequence) fmt.Println("Current wallet sequence:", info.AccountData.Sequence)
fmt.Println() fmt.Println()
fmt.Println("Submitting TicketCreate transaction...") fmt.Println("Submitting TicketCreate transaction...")
tc := &transaction.TicketCreate{ tc := &transaction.TicketCreate{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w.GetAddress(), Account: w.GetAddress(),
@@ -77,9 +77,9 @@ func main() {
return return
} }
fmt.Println("TicketCreate transaction submitted") fmt.Println("TicketCreate transaction submitted")
fmt.Printf("🌐 Hash: %s\n", res.Hash) fmt.Printf("Hash: %s\n", res.Hash)
fmt.Printf("🌐 Validated: %t\n", res.Validated) fmt.Printf("Validated: %t\n", res.Validated)
fmt.Println() fmt.Println()
objects, err := client.GetAccountObjects(&account.ObjectsRequest{ objects, err := client.GetAccountObjects(&account.ObjectsRequest{
@@ -90,7 +90,7 @@ func main() {
return return
} }
fmt.Println("🌐 Account objects:", objects.AccountObjects[0]["TicketSequence"]) fmt.Println("Account objects:", objects.AccountObjects[0]["TicketSequence"])
seq, err := objects.AccountObjects[0]["TicketSequence"].(json.Number).Int64() seq, err := objects.AccountObjects[0]["TicketSequence"].(json.Number).Int64()
if err != nil { if err != nil {
@@ -98,7 +98,7 @@ func main() {
return return
} }
fmt.Println("Submitting AccountSet transaction...") fmt.Println("Submitting AccountSet transaction...")
as := &transaction.AccountSet{ as := &transaction.AccountSet{
BaseTx: transaction.BaseTx{ BaseTx: transaction.BaseTx{
Account: w.GetAddress(), Account: w.GetAddress(),
@@ -128,7 +128,7 @@ func main() {
return return
} }
fmt.Println("AccountSet transaction submitted") fmt.Println("AccountSet transaction submitted")
fmt.Printf("🌐 Hash: %s\n", res.Hash) fmt.Printf("Hash: %s\n", res.Hash)
fmt.Printf("🌐 Validated: %t\n", res.Validated) fmt.Printf("Validated: %t\n", res.Validated)
} }