-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
孙显松
committed
Nov 20, 2020
1 parent
797c47d
commit 8cf1f86
Showing
11 changed files
with
173 additions
and
27 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build: | ||
GOOS=windows GOARCH=amd64 go build -o wcli.exe | ||
go build -o wcli |
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 | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
|
||
"github.com/dabankio/wallet-core/bip44" | ||
"github.com/dabankio/wallet-core/wallet" | ||
) | ||
|
||
var pass string | ||
var mne string | ||
|
||
func init() { | ||
flag.StringVar(&pass, "pass", "", "-pass xxx") | ||
flag.StringVar(&mne, "mne", "", "-mne xxx") | ||
flag.Parse() | ||
} | ||
|
||
func main() { | ||
const s = "BBC" | ||
|
||
options := &wallet.WalletOptions{} | ||
options.Add(wallet.WithPathFormat(bip44.FullPathFormat)) //m/44'/%d'/0'/0/0, 确保兼容imToken | ||
options.Add(wallet.WithPassword(pass)) //确保兼容imToken | ||
options.Add(wallet.WithShareAccountWithParentChain(true)) //USDT BTC共用地址 | ||
options.Add(wallet.WithFlag(wallet.FlagBBCUseStandardBip44ID)) //BBC使用标准bip44 ID | ||
options.Add(wallet.WithFlag(wallet.FlagMKFUseBBCBip44ID)) //MKF 和BBC共用地址 | ||
|
||
w, err := wallet.BuildWalletFromMnemonic(mne, true, options) | ||
pe(err) | ||
|
||
privk, err := w.DerivePrivateKey(s) | ||
pe(err) | ||
pubk, err := w.DerivePublicKey(s) | ||
pe(err) | ||
address, err := w.DeriveAddress(s) | ||
pe(err) | ||
|
||
fmt.Println("addr", address) | ||
fmt.Println("pubk", pubk) | ||
fmt.Println("prvk", privk) | ||
} | ||
|
||
func pe(e error) { | ||
if e != nil { | ||
panic(e) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package core | ||
|
||
func PaddedAppend(size uint, dst, src []byte) []byte { | ||
for i := 0; i < int(size)-len(src); i++ { | ||
dst = append(dst, 0) | ||
} | ||
return append(dst, src...) | ||
} |
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