Skip to content

Commit

Permalink
Merge pull request #177 from BuxOrg/feat/BUX-434/ChangeReadme
Browse files Browse the repository at this point in the history
BUX-434/Change Readme
  • Loading branch information
Nazarii-4chain authored Jan 24, 2024
2 parents 032eda5 + 6f88115 commit 49c96fe
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
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)

}

0 comments on commit 49c96fe

Please sign in to comment.