generated from mrz1836/go-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(SPV-904) update endpoint use cases
- Loading branch information
1 parent
f788b2b
commit 8cea9ca
Showing
7 changed files
with
154 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
Package main - access_key example | ||
*/ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
walletclient "github.com/bitcoin-sv/spv-wallet-go-client" | ||
"github.com/bitcoin-sv/spv-wallet-go-client/examples" | ||
) | ||
|
||
func main() { | ||
defer examples.HandlePanic() | ||
|
||
examples.CheckIfXPrivExists() | ||
|
||
const server = "http://localhost:3003/v1" | ||
|
||
client := walletclient.NewWithXPriv(server, examples.ExampleXPriv) | ||
ctx := context.Background() | ||
|
||
metadata := map[string]any{"some_metadata": "example"} | ||
createdAccessKey, err := client.CreateAccessKey(ctx, metadata) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
fmt.Println("Created access key ID: ", createdAccessKey.ID) | ||
fmt.Println("Metadata: ", createdAccessKey.Metadata) | ||
fmt.Println("Created at: ", createdAccessKey.CreatedAt) | ||
|
||
fetchedAccessKey, err := client.GetAccessKey(ctx, createdAccessKey.ID) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
fmt.Println("Fetched access key ID: ", fetchedAccessKey.ID) | ||
|
||
revokedAccessKey, err := client.RevokeAccessKey(ctx, createdAccessKey.ID) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
fmt.Println("Revoked access key ID: ", revokedAccessKey.ID) | ||
fmt.Println("Revoked at: ", revokedAccessKey.RevokedAt) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
Package main - get_shared_config example | ||
*/ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
walletclient "github.com/bitcoin-sv/spv-wallet-go-client" | ||
"github.com/bitcoin-sv/spv-wallet-go-client/examples" | ||
) | ||
|
||
func main() { | ||
defer examples.HandlePanic() | ||
|
||
examples.CheckIfXPrivExists() | ||
|
||
const server = "http://localhost:3003/v1" | ||
|
||
client := walletclient.NewWithXPriv(server, examples.ExampleXPriv) | ||
ctx := context.Background() | ||
|
||
sharedConfig, err := client.GetSharedConfig(ctx) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
fmt.Println("Shared config (PaymailDomains): ", sharedConfig.PaymailDomains) | ||
fmt.Println("Shared config (ExperimentalFeatures): ", sharedConfig.ExperimentalFeatures) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
Package main - update_xpub_metadata example | ||
*/ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
walletclient "github.com/bitcoin-sv/spv-wallet-go-client" | ||
"github.com/bitcoin-sv/spv-wallet-go-client/examples" | ||
) | ||
|
||
func main() { | ||
defer examples.HandlePanic() | ||
|
||
examples.CheckIfXPrivExists() | ||
|
||
const server = "http://localhost:3003/v1" | ||
|
||
client := walletclient.NewWithXPriv(server, examples.ExampleXPriv) | ||
ctx := context.Background() | ||
|
||
xpubInfo, err := client.GetXPub(ctx) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
fmt.Println("XPub metadata: ", xpubInfo.Metadata) | ||
fmt.Println("XPub (updated_at): ", xpubInfo.UpdatedAt) | ||
|
||
metadata := map[string]any{"some_metadata_2": "example2"} | ||
updatedXpubInfo, err := client.UpdateXPubMetadata(ctx, metadata) | ||
if err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
fmt.Println("Updated XPub metadata: ", updatedXpubInfo.Metadata) | ||
fmt.Println("Updated XPub (updated_at): ", updatedXpubInfo.UpdatedAt) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters