go-blockchain/rpc/mining.go
Claude 04fcf75ae5
feat(rpc): SubmitBlock endpoint
Co-Authored-By: Charon <charon@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 21:11:44 +00:00

26 lines
733 B
Go

// Copyright (c) 2017-2026 Lethean (https://lt.hn)
//
// Licensed under the European Union Public Licence (EUPL) version 1.2.
// SPDX-License-Identifier: EUPL-1.2
package rpc
import "fmt"
// SubmitBlock submits a mined block to the daemon.
// The hexBlob is the hex-encoded serialised block.
// Note: submitblock takes a JSON array as params, not an object.
func (c *Client) SubmitBlock(hexBlob string) error {
// submitblock expects params as an array: ["hexblob"]
params := []string{hexBlob}
var resp struct {
Status string `json:"status"`
}
if err := c.call("submitblock", params, &resp); err != nil {
return err
}
if resp.Status != "OK" {
return fmt.Errorf("submitblock: status %q", resp.Status)
}
return nil
}