From 87e771d2287b24f11eeda9a12a217581fe7b5454 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 04:14:40 +0100 Subject: [PATCH] feat: add 3 wallet Core actions (create, address, seed) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- actions.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/actions.go b/actions.go index a2c0b3f..fc88254 100644 --- a/actions.go +++ b/actions.go @@ -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} +}