mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
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
32 lines
775 B
Go
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
|
|
}
|