Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUX-434/Change Readme #177

Merged
merged 7 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,31 @@ Read more about this Go project's [code standards](.github/CODE_STANDARDS.md).

<br/>

## Usage


```
// http example
func main() {

// Generate keys
keys, _ := xpriv.Generate()

// Create a client
client, _ := buxclient.New(
buxclient.WithXPriv(keys.XPriv()),
buxclient.WithHTTP("localhost:3001"),
buxclient.WithSignRequest(true))

fmt.Println(client.IsSignRequest())
}

```

Checkout all the [examples](examples)!

<br/>

## Contributing
All kinds of contributions are welcome!
<br/>
Expand Down
4 changes: 3 additions & 1 deletion examples/http/http.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"github.com/BuxOrg/go-buxclient"
"github.com/BuxOrg/go-buxclient/xpriv"
)
Expand All @@ -11,9 +12,10 @@ func main() {
keys, _ := xpriv.Generate()

// Create a client
_, _ = buxclient.New(
client, _ := buxclient.New(
buxclient.WithXPriv(keys.XPriv()),
buxclient.WithHTTP("localhost:3001"),
buxclient.WithSignRequest(true),
)
fmt.Println(client.IsSignRequest())
}
15 changes: 13 additions & 2 deletions examples/register_xpub/register_xpub.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"fmt"
buxmodels "github.com/BuxOrg/bux-models"
"github.com/BuxOrg/go-buxclient"
"github.com/BuxOrg/go-buxclient/xpriv"
Expand All @@ -14,12 +15,22 @@ func main() {
// Create a client
buxClient, _ := buxclient.New(
buxclient.WithXPriv(keys.XPriv()),
buxclient.WithHTTP("localhost:3001"),
buxclient.WithHTTP("localhost:3003/v1"),
buxclient.WithSignRequest(true),
)

ctx := context.Background()

_ = buxClient.NewXpub(
context.Background(), keys.XPub().String(), &buxmodels.Metadata{"example_field": "example_data"},
ctx, keys.XPub().String(), &buxmodels.Metadata{"example_field": "example_data"},
)

xpubKey, err := buxClient.GetXPub(ctx)

if err != nil {
fmt.Println(err)
}

fmt.Println(xpubKey)

}
Loading