dogecoin

package
v0.0.0-...-2838e17 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package dogecoin implements Dogecoin transaction building and signing for the manager service. Dogecoin uses the same transaction format as Bitcoin, so we leverage btcsuite libraries.

Package dogecoin implements Dogecoin transaction building and signing for the manager service.

Index

Constants

View Source
const SighashAll = txscript.SigHashAll

SighashAll is the sighash type for signing all inputs and outputs.

Variables

This section is empty.

Functions

func ApplySignatureToInput

func ApplySignatureToInput(
	tx *wire.MsgTx,
	inputIndex int,
	signatures [][]byte,
	redeemScript []byte,
) error

ApplySignatureToInput applies a signature to a specific input for P2SH multisig. This builds the scriptSig: OP_0 <sig1> <sig2> ... <redeemScript>

func BuildP2PKHScriptPubKey

func BuildP2PKHScriptPubKey(pubkeyHash []byte) ([]byte, error)

BuildP2PKHScriptPubKey builds a P2PKH scriptPubKey for a 20-byte pubkey hash. Format: OP_DUP OP_HASH160 <20-byte hash> OP_EQUALVERIFY OP_CHECKSIG

func BuildP2SHAddress

func BuildP2SHAddress(redeemScript []byte) []byte

BuildP2SHAddress computes the P2SH address (script hash) for a redeem script. Returns the 20-byte script hash.

func BuildP2SHScriptPubKey

func BuildP2SHScriptPubKey(scriptHash []byte) ([]byte, error)

BuildP2SHScriptPubKey builds a P2SH scriptPubKey for a 20-byte script hash. Format: OP_HASH160 <20-byte hash> OP_EQUAL

func BuildRedeemScript

func BuildRedeemScript(
	emitterChain vaa.ChainID,
	emitterContract vaa.Address,
	recipientAddress [32]byte,
	m uint8,
	pubkeys [][]byte,
) ([]byte, error)

BuildRedeemScript builds the redeem script as specified in the whitepaper. Format:

<emitter_chain>     (2 bytes, u16 BE)
<emitter_contract>  (32 bytes)
OP_2DROP
<recipient_address> (32 bytes)
OP_DROP
OP_M <pubkeys...> OP_N OP_CHECKMULTISIG

func BuildScriptPubKey

func BuildScriptPubKey(addrType vaa.UTXOAddressType, address []byte) ([]byte, error)

BuildScriptPubKey builds a scriptPubKey for the given address type and address bytes.

func DoubleSha256

func DoubleSha256(data []byte) []byte

DoubleSha256 computes the double SHA256 hash used in Bitcoin/Dogecoin.

func EncodeDERSignature

func EncodeDERSignature(r, s []byte, hashType txscript.SigHashType) []byte

EncodeDERSignature ensures a signature is properly DER-encoded with sighash type appended. The input should be the raw ECDSA signature (r, s) values.

func Hash160

func Hash160(data []byte) []byte

Hash160 computes RIPEMD160(SHA256(data)), used for address generation.

func VoutToBytes

func VoutToBytes(vout uint32) []byte

VoutToBytes converts a vout index to little-endian bytes.

Types

type UnsignedTransaction

type UnsignedTransaction struct {
	// Tx is the unsigned wire transaction.
	Tx *wire.MsgTx
	// RedeemScripts contains the redeem script for each input, indexed by input index.
	RedeemScripts [][]byte
}

UnsignedTransaction represents an unsigned Dogecoin transaction with metadata needed for signing.

func BuildUnsignedTransaction

func BuildUnsignedTransaction(
	payload *vaa.UTXOUnlockPayload,
	redeemScript []byte,
) (*UnsignedTransaction, error)

BuildUnsignedTransaction constructs an unsigned Dogecoin transaction from a UTXO unlock payload. The redeemScript is used for P2SH inputs and must be provided for sighash computation.

func (*UnsignedTransaction) ComputeAllSighashes

func (ut *UnsignedTransaction) ComputeAllSighashes(hashType txscript.SigHashType) ([][]byte, error)

ComputeAllSighashes computes the sighash for all inputs.

func (*UnsignedTransaction) ComputeSighash

func (ut *UnsignedTransaction) ComputeSighash(inputIndex int, hashType txscript.SigHashType) ([]byte, error)

ComputeSighash computes the sighash for a specific input using the legacy sighash algorithm. This is used for P2SH multisig signing in Dogecoin.

func (*UnsignedTransaction) InputCount

func (ut *UnsignedTransaction) InputCount() int

InputCount returns the number of inputs in the transaction.

func (*UnsignedTransaction) OutputCount

func (ut *UnsignedTransaction) OutputCount() int

OutputCount returns the number of outputs in the transaction.

func (*UnsignedTransaction) SerializeForBroadcast

func (ut *UnsignedTransaction) SerializeForBroadcast() ([]byte, error)

SerializeForBroadcast serializes the transaction for network broadcast. Note: This should only be called after all signatures have been applied.

func (*UnsignedTransaction) TxHash

func (ut *UnsignedTransaction) TxHash() chainhash.Hash

TxHash returns the transaction hash (txid) in the standard Bitcoin/Dogecoin format.

Jump to

Keyboard shortcuts

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