Documentation
¶
Overview ¶
Package tx builds, signs (via external signers), and assembles single-MsgSend SOVR transactions under SIGN_MODE_DIRECT (contracts/go-client-api.md §tx).
SignerInfo always carries the sender's public key: SignDoc requires the 33-byte compressed secp256k1 key up front and embeds it in AuthInfo.SignerInfos[0].PublicKey before the sign-doc bytes are fixed. Cosmos SDK v0.53 nodes dereference SignerInfo.PublicKey unconditionally during CheckTx signature verification, so a transaction without it is unbroadcastable regardless of the account's on-chain state (KF-1).
Index ¶
Constants ¶
const ( Bech32PrefixAccount = "sovr" Bech32PrefixValidator = "sovrvaloper" Denom = "usovr" MsgSendTypeURL = "/cosmos.bank.v1beta1.MsgSend" )
Variables ¶
var ( ErrInvalidAddress = errors.New("invalid account address") ErrInvalidAmount = errors.New("amount must be a base-10 integer string") ErrAmountNotPositive = errors.New("amount must be greater than zero") ErrAmountTooLarge = errors.New("amount exceeds the 256-bit integer range") ErrInvalidFee = errors.New("invalid fee amount") ErrInvalidGasLimit = errors.New("gas limit must be greater than zero") ErrEmptyChainID = errors.New("chain ID must not be empty") ErrNotBuilt = errors.New("UnsignedTx must be created via BuildMsgSend") ErrNoSignDoc = errors.New("SignDoc must be called before Assemble") ErrInvalidSignature = errors.New("signature is not a valid low-S secp256k1 signature over the sign doc") ErrInvalidPubKey = errors.New("public key is not a 33-byte compressed secp256k1 key") ErrPubKeyMismatch = errors.New("public key does not derive the sender address") ErrMalformedSignDoc = errors.New("malformed sign doc") ErrSummaryMismatch = errors.New("summary does not match sign doc") )
Functions ¶
func Assemble ¶
func Assemble(u *UnsignedTx, sig SignatureResponse) ([]byte, string, error)
Assemble verifies sig over the sign doc, checks the pubkey derives the sender address AND equals the key embedded in AuthInfo at SignDoc time, and returns the broadcastable TxRaw bytes plus the transaction hash (uppercase hex SHA-256 of the signed bytes). The signed body/auth-info bytes are byte-identical to the ones inside the sign doc.
func VerifySummary ¶
func VerifySummary(signDocBytes []byte, summary SigningSummary) error
VerifySummary re-derives the summary from signDocBytes and compares it field-for-field against the provided one (signer/adapter cross-check per contracts/signer-interface.md).
Types ¶
type SignatureResponse ¶
SignatureResponse is the external signer's output: 64-byte R||S low-S signature over SHA-256(signDocBytes) and the 33-byte compressed pubkey.
type SigningSummary ¶
type SigningSummary = signer.SigningSummary
SigningSummary mirrors contracts/signer-interface.md field-for-field. It is always derived from sign-doc bytes (DeriveSummary), never from caller inputs. SigningSummary is shared with the signer boundary — one type across the kit so builders, signers, and the adapter verify the same shape (contract: signer-interface.md).
func DeriveSummary ¶
func DeriveSummary(signDocBytes []byte) (SigningSummary, error)
DeriveSummary decodes signDocBytes and fills a SigningSummary from the decoded contents only. Any doc shape this summary cannot faithfully describe (extra messages, unknown fields, fee payer/granter, timeouts, non-usovr coins, non-DIRECT modes, a missing/foreign embedded pubkey) is rejected: the summary is the verification source at the signer trust boundary. The signer info MUST embed a 33-byte compressed secp256k1 public key that derives the sender address (KF-1: SDK v0.53 CheckTx requires it).
type UnsignedTx ¶
type UnsignedTx struct {
// contains filtered or unexported fields
}
UnsignedTx is a single-MsgSend transaction between BuildMsgSend and Assemble. Not safe for concurrent use.
func BuildMsgSend ¶
func BuildMsgSend(from, to, amountBaseUnits, memo string) (*UnsignedTx, error)
BuildMsgSend creates a transaction carrying exactly one /cosmos.bank.v1beta1.MsgSend of amountBaseUnits usovr (FR-036).
func (*UnsignedTx) SignDoc ¶
func (u *UnsignedTx) SignDoc(chainID string, accountNumber, sequence uint64, fee Fee, pubKeyCompressed []byte) ([]byte, SigningSummary, error)
SignDoc returns the ADR-020 SIGN_MODE_DIRECT SignDoc bytes for this transaction plus a SigningSummary decoded back out of those exact bytes.
pubKeyCompressed is the sender's 33-byte compressed secp256k1 public key (the signer boundary's GetPublicKey provides it). It must derive the sender address and is embedded in AuthInfo.SignerInfos[0].PublicKey BEFORE the sign-doc bytes are computed — SDK v0.53 CheckTx dereferences it unconditionally, so it can never be deferred to Assemble time.