feat: add 3 wallet Core actions (create, address, seed)
Some checks are pending
Security Scan / security (push) Waiting to run
Test / Test (push) Waiting to run

blockchain.wallet.create — generate wallet, return address + seed
blockchain.wallet.address — derive all address types from seed
blockchain.wallet.seed — generate fresh mnemonic seed

19 total Core actions. All pure core.Options → core.Result.
No banned imports in action handlers.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 04:14:40 +01:00
parent 24fee95962
commit 87e771d228
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -9,6 +9,7 @@ import (
"dappco.re/go/core"
"dappco.re/go/core/blockchain/chain"
"dappco.re/go/core/blockchain/wallet"
)
// RegisterActions registers all blockchain actions with a Core instance.
@ -238,3 +239,52 @@ func parseActionComment(comment string) map[string]string {
}
return parsed
}
// RegisterWalletActions registers wallet-related Core actions.
//
// blockchain.RegisterWalletActions(c)
func RegisterWalletActions(c *core.Core) {
c.Action("blockchain.wallet.create", actionWalletCreate)
c.Action("blockchain.wallet.address", actionWalletAddress)
c.Action("blockchain.wallet.seed", actionWalletSeed)
}
func actionWalletCreate(ctx context.Context, opts core.Options) core.Result {
account, err := wallet.GenerateAccount()
if err != nil {
return core.Result{OK: false}
}
addr := account.Address()
seed, _ := account.ToSeed()
return core.Result{Value: map[string]interface{}{
"address": addr.Encode(StandardPrefix),
"seed": seed,
}, OK: true}
}
func actionWalletAddress(ctx context.Context, opts core.Options) core.Result {
seed := opts.String("seed")
if seed == "" {
return core.Result{OK: false}
}
account, err := wallet.RestoreFromSeed(seed)
if err != nil {
return core.Result{OK: false}
}
addr := account.Address()
return core.Result{Value: map[string]interface{}{
"standard": addr.Encode(StandardPrefix),
"integrated": addr.Encode(IntegratedPrefix),
"auditable": addr.Encode(AuditablePrefix),
}, OK: true}
}
func actionWalletSeed(ctx context.Context, opts core.Options) core.Result {
// Generate a fresh seed (no wallet file needed)
account, err := wallet.GenerateAccount()
if err != nil {
return core.Result{OK: false}
}
seed, _ := account.ToSeed()
return core.Result{Value: seed, OK: true}
}