-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from maestro-org/release-please--branches--mai…
…n--changes--next release: 0.1.0-alpha.4
- Loading branch information
Showing
51 changed files
with
145 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
".": "0.1.0-alpha.3" | ||
".": "0.1.0-alpha.4" | ||
} |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# Maestro Bitcoin Go SDK | ||
# Maestro Bitcoin Go API Library | ||
|
||
<a href="https://pkg.go.dev/github.com/maestro-org/maestro-bitcoin-go-sdk"><img src="https://pkg.go.dev/badge/github.com/maestro-org/maestro-bitcoin-go-sdk.svg" alt="Go Reference"></a> | ||
|
||
The Maestro Bitcoin Go SDK provides convenient access to [the Maestro Bitcoin REST | ||
The Maestro Bitcoin Go library provides convenient access to [the Maestro REST | ||
API](https://docs.gomaestro.org/) from applications written in Go. The full API of this library can be found in [api.md](api.md). | ||
|
||
## Installation | ||
|
@@ -22,7 +22,7 @@ Or to pin the version: | |
<!-- x-release-please-start-version --> | ||
|
||
```sh | ||
go get -u 'github.com/maestro-org/[email protected].3' | ||
go get -u 'github.com/maestro-org/[email protected].4' | ||
``` | ||
|
||
<!-- x-release-please-end --> | ||
|
@@ -49,13 +49,17 @@ import ( | |
func main() { | ||
client := maestrobitcoingosdk.NewClient( | ||
option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("API_KEY") | ||
option.WithEnvironmentMainnet(), // defaults to option.WithEnvironmentMainnet() | ||
option.WithEnvironmentMainnet(), // or option.WithEnvironmentTestnet() | option.WithEnvironmentDefault(); defaults to option.WithEnvironmentTestnet() | ||
) | ||
paginatedUtxo, err := client.Addresses.Utxos.List( | ||
context.TODO(), | ||
"REPLACE_ME", | ||
maestrobitcoingosdk.AddressUtxoListParams{}, | ||
) | ||
timestampedBlock, err := client.Blocks.Latest.Get(context.TODO()) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
fmt.Printf("%+v\n", timestampedBlock.Data) | ||
fmt.Printf("%+v\n", paginatedUtxo.Data) | ||
} | ||
|
||
``` | ||
|
@@ -144,7 +148,7 @@ client := maestrobitcoingosdk.NewClient( | |
option.WithHeader("X-Some-Header", "custom_header_info"), | ||
) | ||
|
||
client.Blocks.Latest.Get(context.TODO(), ..., | ||
client.Addresses.Utxos.List(context.TODO(), ..., | ||
// Override the header | ||
option.WithHeader("X-Some-Header", "some_other_custom_header_info"), | ||
// Add an undocumented field to the request body, using sjson syntax | ||
|
@@ -173,14 +177,18 @@ When the API returns a non-success status code, we return an error with type | |
To handle errors, we recommend that you use the `errors.As` pattern: | ||
|
||
```go | ||
_, err := client.Blocks.Latest.Get(context.TODO()) | ||
_, err := client.Addresses.Utxos.List( | ||
context.TODO(), | ||
"REPLACE_ME", | ||
maestrobitcoingosdk.AddressUtxoListParams{}, | ||
) | ||
if err != nil { | ||
var apierr *maestrobitcoingosdk.Error | ||
if errors.As(err, &apierr) { | ||
println(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request | ||
println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response | ||
} | ||
panic(err.Error()) // GET "/blocks/latest": 400 Bad Request { ... } | ||
panic(err.Error()) // GET "/addresses/{address}/utxos": 400 Bad Request { ... } | ||
} | ||
``` | ||
|
||
|
@@ -198,8 +206,10 @@ To set a per-retry timeout, use `option.WithRequestTimeout()`. | |
// This sets the timeout for the request, including all the retries. | ||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) | ||
defer cancel() | ||
client.Blocks.Latest.Get( | ||
client.Addresses.Utxos.List( | ||
ctx, | ||
"REPLACE_ME", | ||
maestrobitcoingosdk.AddressUtxoListParams{}, | ||
// This sets the per-retry timeout | ||
option.WithRequestTimeout(20*time.Second), | ||
) | ||
|
@@ -233,7 +243,12 @@ client := maestrobitcoingosdk.NewClient( | |
) | ||
|
||
// Override per-request: | ||
client.Blocks.Latest.Get(context.TODO(), option.WithMaxRetries(5)) | ||
client.Addresses.Utxos.List( | ||
context.TODO(), | ||
"REPLACE_ME", | ||
maestrobitcoingosdk.AddressUtxoListParams{}, | ||
option.WithMaxRetries(5), | ||
) | ||
``` | ||
|
||
### Making custom/undocumented requests | ||
|
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
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
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
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
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
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
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
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
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
Oops, something went wrong.