A Go implementation of bitcoin-backup, providing password-based encryption for Bitcoin wallet backups compatible with the bitcoin-backup TypeScript library.
- Full compatibility with TypeScript bitcoin-backup format
- AES-256-GCM encryption with PBKDF2 key derivation
- Support for multiple backup types (BAP Master, BAP Member, WIF, 1Sat)
- Automatic iteration fallback (600k/100k) for legacy support
- Type-safe Go implementation
go get github.com/b-open-io/go-bitcoin-image
package main
import (
"fmt"
"log"
bitcoinimage "github.com/b-open-io/go-bitcoin-image"
)
func main() {
// Create a BAP member backup
backup := bitcoinimage.BapMemberBackup{
WIF: "L1aW4aubDFB7yfras2S1mN3bqg9nwySY8nkoLmJebSLD5BWv3ENZ",
ID: "bap-id-123",
Label: "My Identity",
}
// Encrypt with password
result, err := bitcoinimage.EncryptBackup(backup, "my-secure-password")
if err != nil {
log.Fatal(err)
}
fmt.Println("Encrypted backup:", result.Encrypted)
}
// Decrypt to map
decrypted, err := bitcoinimage.DecryptBackup(encryptedString, "my-secure-password")
if err != nil {
log.Fatal(err)
}
// Or decrypt to specific type
member, err := bitcoinimage.DecryptToStruct[bitcoinimage.BapMemberBackup](encryptedString, "my-secure-password")
if err != nil {
log.Fatal(err)
}
- BapMasterBackup: HD wallet master key with mnemonic
- MasterBackupType42: Type 42 derivation master backup
- BapMemberBackup: Individual BAP identity
- WifBackup: Simple WIF private key
- OneSatBackup: 1Sat ordinals wallet (3 keys)
This library maintains full compatibility with the TypeScript bitcoin-backup library, ensuring seamless interoperability between JavaScript/TypeScript and Go applications.
MIT License