Files
commerce/models/wallet/keygen_bitcoin.go
zeekay 1943f1c093 Hanzo Commerce
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans,
usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0.

Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
2026-09-23 21:52:16 -07:00

32 lines
775 B
Go

package wallet
import (
"github.com/hanzoai/commerce/models/blockchains"
"github.com/hanzoai/commerce/thirdparty/bitcoin"
)
func init() {
for _, typ := range []blockchains.Type{blockchains.BitcoinType, blockchains.BitcoinTestnetType} {
RegisterKeyGen(typ, bitcoinKeyGen)
}
}
func bitcoinKeyGen(typ blockchains.Type) (priv, pub, address string, err error) {
priv, pub, err = bitcoin.GenerateKeyPair()
if err != nil {
return "", "", "", err
}
switch typ {
case blockchains.BitcoinType:
address, _, err = bitcoin.PubKeyToAddress(pub, false)
case blockchains.BitcoinTestnetType:
address, _, err = bitcoin.PubKeyToAddress(pub, true)
default:
err = ErrorInvalidTypeSpecified
}
if err != nil {
return "", "", "", err
}
return priv, pub, address, nil
}