chainview

package
v0.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package chainview answers, from the network's own words and the node's view of outputs, whether a transaction can still mine: what a settlement leg's error means, and which input another transaction spent, in words over bcommon's view of the node (nodeapi.Asset.SpentElsewhere). A sender's sweep and a payee's payment both need it, since a leg that accepted a transaction (arcade has answered ACCEPTED_BY_NETWORK for a transaction whose input was already spent and mined) or that answers nothing (the tcp ingress) cannot be taken at its word.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func RefusedAnswer

func RefusedAnswer(err error) (string, bool)

RefusedAnswer reports whether a settlement leg's error is the network's definitive refusal of these bytes, and in what words:

  • arcade's verdict REJECTED or DOUBLE_SPEND_ATTEMPTED (bcommon words it "arcade refused" or "the network refused");
  • arcade's HTTP 422, or 460 to 475, its documented validation refusals (malformed, inputs, fee, a conflicting transaction);
  • a node's RPC error -25 (RPC_VERIFY_ERROR) or -26 (RPC_VERIFY_REJECTED), except a full mempool or a chain too long, which pass.

Everything else is transient: a leg that cannot be reached, a 5xx, a 429, no verdict yet.

Example

A settlement leg's error is either the network's definitive refusal of these bytes, which no retry changes, or something transient.

package main

import (
	"errors"
	"fmt"

	"github.com/lightwebinc/bcommon/chainview"
)

func main() {
	for _, e := range []string{
		"publish: arcade refused 5f2c: REJECTED: bad-txns-inputs-missingorspent",
		"publish: sendrawtransaction: rpc error -26: mandatory-script-verify-flag-failed",
		"publish: sendrawtransaction: rpc error -26: mempool full",
		"publish: arcade answered 503: busy",
		"context deadline exceeded",
	} {
		_, refused := chainview.RefusedAnswer(errors.New(e))
		fmt.Printf("%t  %s\n", refused, e)
	}
}
Output:
true  publish: arcade refused 5f2c: REJECTED: bad-txns-inputs-missingorspent
true  publish: sendrawtransaction: rpc error -26: mandatory-script-verify-flag-failed
false  publish: sendrawtransaction: rpc error -26: mempool full
false  publish: arcade answered 503: busy
false  context deadline exceeded

func SpentElsewhere

func SpentElsewhere(ctx context.Context, a *nodeapi.Asset, tx *transaction.Transaction) string

SpentElsewhere names the first input of tx that the node shows spent by another transaction, in words, or "" when none is: then tx can still mine as far as its inputs go. An input the node cannot answer for is passed over. The node's view is bcommon's (nodeapi.Asset.SpentElsewhere); this only words it.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL