Skip to content

b-open-io/go-bitcoin-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-bitcoin-image

A Go implementation of bitcoin-backup, providing password-based encryption for Bitcoin wallet backups compatible with the bitcoin-backup TypeScript library.

Features

  • 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

Installation

go get github.com/b-open-io/go-bitcoin-image

Usage

Encrypting a Backup

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)
}

Decrypting a Backup

// 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)
}

Backup Types

  • 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)

Compatibility

This library maintains full compatibility with the TypeScript bitcoin-backup library, ensuring seamless interoperability between JavaScript/TypeScript and Go applications.

License

MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages