Skip to content

Commit 84cea65

Browse files
Merge pull request #162 from XRPLF/chore/replace-bip32-bip39-deps
chore(bip32, bip39): remove "github.com/tyler-smith/go-bip32", "github.com/tyler-smith/go-bip39" with "github.com/bsv-blockchain/go-sdk"
2 parents f481a46 + f970e44 commit 84cea65

File tree

6 files changed

+37
-38
lines changed

6 files changed

+37
-38
lines changed

.github/workflows/xrpl-go-ci-lint-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@v4
1313
- uses: actions/setup-go@v4
1414
with:
15-
go-version: "1.23"
15+
go-version: "1.24"
1616
cache: true
1717

1818
- name: Install golangci-lint

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23-alpine AS install
1+
FROM golang:1.24-alpine AS install
22
RUN apk add --no-cache make git ca-certificates
33

44
WORKDIR /app

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
The `xrpl-go` library provides a Go implementation for interacting with the XRP Ledger. From serialization to signing transactions, the library allows users to work with the most
99
complex elements of the XRP Ledger. A full library of models for all transactions and core server rippled API objects are provided.
1010

11-
## Disclaimer
12-
This library is still in development and not yet intended for production use.
13-
1411
## Requirements
1512

1613
Requiring Go version `1.22.0` and later.

go.mod

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
module github.com/Peersyst/xrpl-go
22

3-
go 1.23.0
4-
5-
toolchain go1.23.10
3+
go 1.24.3
64

75
require (
6+
github.com/bsv-blockchain/go-sdk v1.2.9
87
github.com/btcsuite/btcd/btcec/v2 v2.3.4
98
github.com/decred/dcrd/crypto/ripemd160 v1.0.2
109
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
1110
github.com/gorilla/websocket v1.5.0
1211
github.com/mitchellh/mapstructure v1.5.0
13-
github.com/stretchr/testify v1.8.4
14-
github.com/tyler-smith/go-bip32 v1.0.0
15-
github.com/tyler-smith/go-bip39 v1.1.0
12+
github.com/stretchr/testify v1.10.0
1613
github.com/ugorji/go/codec v1.2.11
1714
)
1815

16+
require github.com/pkg/errors v0.9.1 // indirect
17+
1918
require (
20-
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect
21-
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect
2219
github.com/golang/mock v1.6.0 // direct
2320
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
2421
github.com/modern-go/reflect2 v1.0.2 // indirect
@@ -28,7 +25,7 @@ require (
2825
github.com/davecgh/go-spew v1.1.1 // indirect
2926
github.com/json-iterator/go v1.1.12
3027
github.com/pmezard/go-difflib v1.0.0 // indirect
31-
golang.org/x/crypto v0.23.0 // indirect
28+
golang.org/x/crypto v0.41.0 // indirect
3229
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
3330
gopkg.in/yaml.v3 v3.0.1 // indirect
3431
)

go.sum

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e h1:ahyvB3q25YnZWly5Gq1ekg6jcmWaGj/vG/MhF4aisoc=
2-
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:kGUqhHd//musdITWjFvNTHn90WG9bMLBEPQZ17Cmlpw=
3-
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec h1:1Qb69mGp/UtRPn422BH4/Y4Q3SLUrD9KHuDkm8iodFc=
4-
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec/go.mod h1:CD8UlnlLDiqb36L110uqiP2iSflVjx9g/3U9hCI4q2U=
1+
github.com/bsv-blockchain/go-sdk v1.2.9 h1:LwFzuts+J5X7A+ECx0LNowtUgIahCkNNlXckdiEMSDk=
2+
github.com/bsv-blockchain/go-sdk v1.2.9/go.mod h1:KiHWa/hblo3Bzr+IsX11v0sn1E6elGbNX0VXl5mOq6E=
53
github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
64
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
7-
github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e h1:0XBUw73chJ1VYSsfvcPvVT7auykAJce9FpRr10L6Qhw=
8-
github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:P13beTBKr5Q18lJe1rIoLUqjM+CB1zYrRg44ZqGuQSA=
95
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
106
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
117
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -34,17 +30,14 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OH
3430
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
3531
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
3632
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
33+
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
34+
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
3735
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3836
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3937
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
40-
github.com/stretchr/testify v1.1.5-0.20170601210322-f6abca593680/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
4138
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
42-
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
43-
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
44-
github.com/tyler-smith/go-bip32 v1.0.0 h1:sDR9juArbUgX+bO/iblgZnMPeWY1KZMUC2AFUJdv5KE=
45-
github.com/tyler-smith/go-bip32 v1.0.0/go.mod h1:onot+eHknzV4BVPwrzqY5OoVpyCvnwD7lMawL5aQupE=
46-
github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8=
47-
github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U=
39+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
40+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4841
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
4942
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
5043
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
@@ -115,5 +108,3 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
115108
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
116109
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
117110
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
118-
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 h1:Izowp2XBH6Ya6rv+hqbceQyw/gSGoXfH/UPoTGduL54=
119-
launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM=

xrpl/wallet/wallet.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ import (
1414
"github.com/Peersyst/xrpl-go/xrpl/hash"
1515
"github.com/Peersyst/xrpl-go/xrpl/interfaces"
1616
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
17-
"github.com/tyler-smith/go-bip32"
18-
"github.com/tyler-smith/go-bip39"
17+
bip32 "github.com/bsv-blockchain/go-sdk/compat/bip32"
18+
"github.com/bsv-blockchain/go-sdk/compat/bip39"
19+
chaincfg "github.com/bsv-blockchain/go-sdk/transaction/chaincfg"
20+
)
21+
22+
var (
23+
nilHDPrivateKeyID = [4]byte{0x00, 0x00, 0x00, 0x00}
1924
)
2025

2126
// Wallet is a utility for deriving a wallet composed of a keypair (publicKey/privateKey).
@@ -83,31 +88,40 @@ func FromMnemonic(mnemonic string) (*Wallet, error) {
8388
seed := bip39.NewSeed(mnemonic, "")
8489

8590
// Derive the master key
86-
masterKey, err := bip32.NewMasterKey(seed)
91+
92+
params := &chaincfg.Params{
93+
HDPrivateKeyID: nilHDPrivateKeyID,
94+
}
95+
masterKey, err := bip32.NewMaster(seed, params)
8796
if err != nil {
8897
return nil, err
8998
}
9099

91100
// Derive the key using the path m/44'/144'/0'/0/0
92101
path := []uint32{
93-
44 + bip32.FirstHardenedChild,
94-
144 + bip32.FirstHardenedChild,
95-
bip32.FirstHardenedChild,
102+
44 + bip32.HardenedKeyStart,
103+
144 + bip32.HardenedKeyStart,
104+
bip32.HardenedKeyStart,
96105
0,
97106
0,
98107
}
99108

100109
key := masterKey
101110
for _, childNum := range path {
102-
key, err = key.NewChildKey(childNum)
111+
key, err = key.Child(childNum)
103112
if err != nil {
104113
return nil, err
105114
}
106115
}
107116

108117
// Convert the private key to the format expected by the XRPL library
109-
privKey := strings.ToUpper(hex.EncodeToString(key.Key))
110-
pubKey := strings.ToUpper(hex.EncodeToString(key.PublicKey().Key))
118+
ecPriv, err := key.ECPrivKey()
119+
if err != nil {
120+
return nil, err
121+
}
122+
123+
privKey := strings.ToUpper(ecPriv.Hex())
124+
pubKey := strings.ToUpper(hex.EncodeToString(ecPriv.PubKey().Compressed()))
111125

112126
// Derive classic address
113127
classicAddr, err := keypairs.DeriveClassicAddress(pubKey)

0 commit comments

Comments
 (0)