lnutil

package
v0.0.0-...-8c3d3b4 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 34 Imported by: 39

Documentation

Index

Constants

View Source
const (
	MSGID_TEXTCHAT = 0x00 // send a text message

	//Channel creation messages
	MSGID_POINTREQ  = 0x10
	MSGID_POINTRESP = 0x11
	MSGID_CHANDESC  = 0x12
	MSGID_CHANACK   = 0x13
	MSGID_SIGPROOF  = 0x14

	//Channel destruction messages
	MSGID_CLOSEREQ  = 0x20 // close channel
	MSGID_CLOSERESP = 0x21

	//Push Pull Messages
	MSGID_DELTASIG  = 0x30 // pushing funds in channel; request to send
	MSGID_SIGREV    = 0x31 // pulling funds; signing new state and revoking old
	MSGID_GAPSIGREV = 0x32 // resolving collision
	MSGID_REV       = 0x33 // pushing funds; revoking previous channel state

	// HTLC messages
	MSGID_HASHSIG     = 0x34 // Like a deltasig but offers an HTLC
	MSGID_PREIMAGESIG = 0x35 // Like a hashsig but clears an HTLC

	//not implemented
	MSGID_FWDMSG     = 0x40
	MSGID_FWDAUTHREQ = 0x41

	//not implemented
	MSGID_SELFPUSH = 0x50

	//Tower Messages
	MSGID_WATCH_DESC     = 0x60 // desc describes a new channel
	MSGID_WATCH_STATEMSG = 0x61 // commsg is a single state in the channel
	MSGID_WATCH_DELETE   = 0x62 // Watch_clear marks a channel as ok to delete.  No further updates possible.

	//Routing messages
	MSGID_LINK_DESC = 0x70 // Describes a new channel for routing

	//Multihop payment messages
	MSGID_PAY_REQ   = 0x75 // Request payment
	MSGID_PAY_ACK   = 0x76 // Acknowledge payment (share preimage hash)
	MSGID_PAY_SETUP = 0x77 // Setup a payment route

	//Discreet log contracts messages
	MSGID_DLC_OFFER               = 0x90 // Offer a contract
	MSGID_DLC_ACCEPTOFFER         = 0x91 // Accept the contract
	MSGID_DLC_DECLINEOFFER        = 0x92 // Decline the contract
	MSGID_DLC_CONTRACTACK         = 0x93 // Acknowledge an acceptance
	MSGID_DLC_CONTRACTFUNDINGSIGS = 0x94 // Funding signatures
	MSGID_DLC_SIGPROOF            = 0x95 // Sigproof

	//Dual funding messages
	MSGID_DUALFUNDINGREQ     = 0xA0 // Requests funding details (UTXOs, Change address, Pubkey), including our own details and amount needed.
	MSGID_DUALFUNDINGACCEPT  = 0xA1 // Responds with funding details
	MSGID_DUALFUNDINGDECL    = 0xA2 // Declines the funding request
	MSGID_DUALFUNDINGCHANACK = 0xA3 // Acknowledges channel and sends along signatures for funding

	//Remote control messages
	MSGID_REMOTE_RPCREQUEST  = 0xB0 // Contains an RPC request from a remote peer
	MSGID_REMOTE_RPCRESPONSE = 0xB1 // Contains an RPC response to send to a remote peer

	DIGEST_TYPE_SHA256    = 0x00
	DIGEST_TYPE_RIPEMD160 = 0x01
)

id numbers for messages, semi-arbitrary

Variables

View Source
var (
	White  = color.New(color.FgHiWhite).SprintFunc()
	Green  = color.New(color.FgHiGreen).SprintFunc()
	Red    = color.New(color.FgHiRed).SprintFunc()
	Yellow = color.New(color.FgHiYellow).SprintFunc()

	Header   = color.New(color.FgHiCyan).SprintFunc()
	Prompt   = color.New(color.FgHiYellow).SprintFunc()
	OutPoint = color.New(color.FgYellow).SprintFunc()
	Address  = color.New(color.FgMagenta).SprintFunc()
	BTC      = color.New(color.FgHiWhite).SprintFunc()
	Satoshi  = color.New(color.Faint).SprintFunc()
	MicroBTC = color.New(color.FgYellow, color.Faint).SprintFunc()
)

Functions

func AddPrivEZ

func AddPrivEZ(k *koblitz.PrivateKey, b []byte)

AddPrivEZ adds the non-secret scalar to a private key

func AddPubsEZ

func AddPubsEZ(a, b [33]byte) [33]byte

AddPubsEZ is the easy derivation; A + sha(B, A)*G in LN this is used for everything but the revocable pubkey order matters. the first key is the base, the second is the elkpoint.

func Announce

func Announce(priv *koblitz.PrivateKey, port int, litadr string, trackerURL string) error

func BigIntToEncodedBytes

func BigIntToEncodedBytes(a *big.Int) *[32]byte

BigIntToEncodedBytes converts a big integer into its corresponding 32 byte big endian representation.

func BtI32

func BtI32(b []byte) int32

4 byte slice to int32. Returns 7fffffff if something doesn't work.

func BtI64

func BtI64(b []byte) int64

8 bytes to int64 (bitcoin amounts). returns 7fff... if it doesn't work.

func BtU32

func BtU32(b []byte) uint32

4 byte slice to uint32. Returns ffffffff if something doesn't work.

func BtU64

func BtU64(b []byte) uint64

8 bytes to uint64. returns ffff. if it doesn't work.

func CombinePrivKeyAndSubtract

func CombinePrivKeyAndSubtract(k *koblitz.PrivateKey, b []byte) [32]byte

CombinePrivKeyAndSubtract uses the same delinearization scheme as CombinePrivateKeys, but once it gets the combined private key, it subtracts the original base key. It's weird, but it allows the porTxo standard to always add private keys and not need to be aware of different derivation methods.

func CombinePrivKeyWithBytes

func CombinePrivKeyWithBytes(k *koblitz.PrivateKey, b []byte) *koblitz.PrivateKey

PrivKeyCombineBytes combines a private key with a byte slice

func CombinePrivateKeys

func CombinePrivateKeys(keys ...*koblitz.PrivateKey) *koblitz.PrivateKey

CombinePrivateKeys takes a set of private keys and combines them in the same way as done for public keys. This only works if you know *all* of the private keys. If you don't, we'll do something with returning a scalar coefficient... I don't know how that's going to work. Schnorr stuff isn't decided yet.

func CombinePubs

func CombinePubs(a, b [33]byte) [33]byte

CombinePubs takes two 33 byte serialized points, and combines them with the deliniearized combination process. Returns empty array if there's an error.

func CommitScript

func CommitScript(RKey, TKey [33]byte, delay uint16) []byte

CommitScript is the script for 0.13.1: OP_CHECKSIG turned into OP_CHECSIGVERIFY

func DirectWPKHScript

func DirectWPKHScript(pub [33]byte) []byte

func DirectWPKHScriptFromPKH

func DirectWPKHScriptFromPKH(pkh [20]byte) []byte

func DlcCalcOracleSignaturePubKey

func DlcCalcOracleSignaturePubKey(msg []byte, oracleA,
	oracleR [33]byte) ([33]byte, error)

DlcCalcOracleSignaturePubKey computes the predicted signature s*G it's just R - h(R||m)A

func DlcCommitScript

func DlcCommitScript(pubKeyPeer, pubKeyOracleSig, ourPubKey [33]byte,
	delay uint16) []byte

DlcCommitScript makes a script that pays to (PubKeyPeer+PubKeyOracleSig or (OurPubKey and TimeDelay)). We send this over (signed) to the other side. If they publish the TX with the correct script they can use the oracle's signature and their own private key to claim the funds from the output. However, if they send the wrong one, they won't be able to claim the funds and we can claim them once the time delay has passed.

func DlcOutput

func DlcOutput(pkPeer, pkOracleSig, pkOurs [33]byte, value int64) *wire.TxOut

DlcOutput returns a Txo for a particular value that pays to (PubKeyPeer+PubKeyOracleSig or (OurPubKey and TimeDelay))

func ElkPointFromHash

func ElkPointFromHash(in *chainhash.Hash) [33]byte

ElkPoint returns the public key (point) which comes from a node in the elkrem tree (elkrem hash)

func ElkScalar

func ElkScalar(in *chainhash.Hash) chainhash.Hash

ElkScalar returns the private key (scalar) which comes from a node in the elkrem tree (elkrem hash)

func FundTxOut

func FundTxOut(pubA, pubB [33]byte, amt int64) (*wire.TxOut, error)

FundTxOut creates a TxOut for the funding transaction. Give it the two pubkeys and it'll give you the p2sh'd txout. You don't have to remember the p2sh preimage, as long as you remember the pubkeys involved.

func FundTxScript

func FundTxScript(aPub, bPub [33]byte) ([]byte, bool, error)

FundMultiPre generates the non-p2sh'd multisig script for 2 of 2 pubkeys. useful for making transactions spending the fundtx. returns a bool which is true if swapping occurs.

func I32tB

func I32tB(i int32) []byte

int32 to 4 bytes. Always works.

func I64tB

func I64tB(i int64) []byte

int64 to 8 bytes. Always works.

func KeyHashFromPkScript

func KeyHashFromPkScript(pkscript []byte) []byte

KeyHashFromPkScript extracts the 20 or 32 byte hash from a txout PkScript

func LitAdrBytes

func LitAdrBytes(adr string) ([]byte, error)

LitAdrBytes takes a lit address string and returns either 20 or 12 bytes. Or an error.

func LitAdrFromPubkey

func LitAdrFromPubkey(in [33]byte) string

func LitAdrOK

func LitAdrOK(adr string) bool

LitAdrOK make sure the address is OK. Either it has a valid checksum, or it's shortened and doesn't.

func LitFullAdrDecode

func LitFullAdrDecode(in string) ([33]byte, error)

func LitFullKeyAdrEncode

func LitFullKeyAdrEncode(in [33]byte) string

func LitMsgEqual

func LitMsgEqual(msg LitMsg, msg2 LitMsg) bool

func LoadKeyFromFileArg

func LoadKeyFromFileArg(filename string, pass []byte) (*[32]byte, error)

LoadKeyFromFileArg opens the file and returns the key. If the key is unencrypted it will ignore the password argument.

func LoadKeyFromFileInteractive

func LoadKeyFromFileInteractive(filename string) (*[32]byte, error)

LoadKeyFromFileInteractive opens the file 'filename' and presents a keyboard prompt for the passphrase to decrypt it. It returns the key if decryption works, or errors out.

func Lookup

func Lookup(litadr string, trackerURL string, proxyURL string) (string, string, error)

func MultiplyPointByHash

func MultiplyPointByHash(k *koblitz.PublicKey, h chainhash.Hash)

PubKeyMultiplyByHash multiplies a pubkey by a hash. returns nothing, modifies in place. Probably the slowest curve operation.

func NopeString

func NopeString(s string) bool

NopeString returns true if the string means "nope"

func OfferHTLCScript

func OfferHTLCScript(revPKH [20]byte, remotePub [33]byte, RHash [32]byte, localPub [33]byte) []byte

func OldAddressFromPKH

func OldAddressFromPKH(pkHash [20]byte, netID byte) string

OldAddressFromPKH returns a base58 string from a 20 byte pubkey hash

func OptColor

func OptColor(optional ...interface{}) string

func OutPointFromBytes

func OutPointFromBytes(b [36]byte) *wire.OutPoint

OutPointFromBytes gives you an outpoint from 36 bytes. since 36 is enforced, it doesn't error

func OutPointToBytes

func OutPointToBytes(op wire.OutPoint) (b [36]byte)

outPointToBytes turns an outpoint into 36 bytes.

func OutPointsEqual

func OutPointsEqual(a, b wire.OutPoint) bool

need this because before I was comparing pointers maybe? so they were the same outpoint but stored in 2 places so false negative?

func P2WSHify

func P2WSHify(scriptBytes []byte) []byte

P2WSHify takes a script and turns it into a 34 byte long P2WSH PkScript

func ParseAdrString

func ParseAdrString(adr string) (string, string)

ParseAdrString splits a string like "ln1yrvw48uc3atg8e2lzs43mh74m39vl785g4ehem@myhost.co:8191 into a separate pkh part and network part, adding the network part if needed

func ParseAdrStringWithPort

func ParseAdrStringWithPort(adr string) (string, string, uint32)

func PayToPubKeyHashScript

func PayToPubKeyHashScript(pubKeyHash []byte) ([]byte, error)

Not exported in txscript... so we copy and paste here

func PrintTx

func PrintTx(tx *wire.MsgTx)

PrintTx prints out a transaction as serialized byte array to StdOut

func PrivKeyAddBytes

func PrivKeyAddBytes(k *koblitz.PrivateKey, b []byte)

PrivKeyAddBytes adds bytes to a private key. NOTE that this modifies the key in place, overwriting it!!!!! If k is nil, does nothing and doesn't error (k stays nil)

func PubFromHash

func PubFromHash(h chainhash.Hash) (p [33]byte)

HashToPub turns a 32 byte hash into a 33 byte serialized pubkey

func PubKeyAddBytes

func PubKeyAddBytes(k *koblitz.PublicKey, b []byte)

PubKeyAddBytes adds bytes to a public key. NOTE that this modifies the key in place, overwriting it!!!!!

func PubKeyArrAddBytes

func PubKeyArrAddBytes(p *[33]byte, b []byte) error

PubKeyArrAddBytes adds a byte slice to a serialized point. You can't add scalars to a point, so you turn the bytes into a point, then add that point.

func ReadKeyFile

func ReadKeyFile(filename string) (*[32]byte, error)

ReadKeyFile returns an 32 byte key from a file. If there's no file there, it'll make one. If there's a password needed, it'll prompt for one. One stop function.

func ReceiveHTLCScript

func ReceiveHTLCScript(revPKH [20]byte, remotePub [33]byte, RHash [32]byte, localPub [33]byte, locktime uint32) []byte

func ReqColor

func ReqColor(required ...interface{}) string

func SatoshiColor

func SatoshiColor(value int64) string

func SaveKeyToFileArg

func SaveKeyToFileArg(filename string, priv32 *[32]byte, pass []byte) error

saves a 32 byte key to a file, encrypting with pass. if pass is nil or zero length, doesn't encrypt and just saves in hex.

func SaveKeyToFileInteractive

func SaveKeyToFileInteractive(filename string, priv32 *[32]byte) error

saves a 32 byte key to file, prompting for passphrase. if user enters empty passphrase (hits enter twice), will be saved in the clear.

func SettlementTx

func SettlementTx(c *DlcContract, d DlcContractDivision,
	ours bool) (*wire.MsgTx, error)

SettlementTx returns the transaction to settle the contract. ours = the one we generate & sign. Theirs (ours = false) = the one they generated, so we can use their sigs

func TxToString

func TxToString(tx *wire.MsgTx) string

TxToString prints out some info about a transaction. for testing / debugging

func U32tB

func U32tB(i uint32) []byte

uint32 to 4 bytes. Always works.

func U64tB

func U64tB(i uint64) []byte

uint64 to 8 bytes. Always works.

func YupString

func YupString(s string) bool

YupString returns true if the string means "yup"

Types

type ChanAckMsg

type ChanAckMsg struct {
	PeerIdx   uint32
	Outpoint  wire.OutPoint
	ElkZero   [33]byte
	ElkOne    [33]byte
	ElkTwo    [33]byte
	Signature [64]byte
}

message for channel acknowledgement after description message

func NewChanAckMsg

func NewChanAckMsg(peerid uint32, OP wire.OutPoint, ELKZero [33]byte, ELKOne [33]byte, ELKTwo [33]byte, SIG [64]byte) ChanAckMsg

func NewChanAckMsgFromBytes

func NewChanAckMsgFromBytes(b []byte, peerid uint32) (ChanAckMsg, error)

func (ChanAckMsg) Bytes

func (self ChanAckMsg) Bytes() []byte

func (ChanAckMsg) MsgType

func (self ChanAckMsg) MsgType() uint8

func (ChanAckMsg) Peer

func (self ChanAckMsg) Peer() uint32

type ChanDescMsg

type ChanDescMsg struct {
	PeerIdx   uint32
	Outpoint  wire.OutPoint
	PubKey    [33]byte
	RefundPub [33]byte
	HAKDbase  [33]byte

	NextHTLCBase [33]byte
	N2HTLCBase   [33]byte

	CoinType    uint32
	Capacity    int64
	InitPayment int64

	ElkZero [33]byte //consider changing into array in future
	ElkOne  [33]byte
	ElkTwo  [33]byte

	Data [32]byte
}

message with a channel's description

func NewChanDescMsg

func NewChanDescMsg(
	peerid uint32, OP wire.OutPoint,
	pubkey, refund, hakd [33]byte, nextHTLCBase [33]byte, N2HTLCBase [33]byte,
	cointype uint32,
	capacity int64, payment int64,
	ELKZero, ELKOne, ELKTwo [33]byte, data [32]byte) ChanDescMsg

func NewChanDescMsgFromBytes

func NewChanDescMsgFromBytes(b []byte, peerid uint32) (ChanDescMsg, error)

func (ChanDescMsg) Bytes

func (self ChanDescMsg) Bytes() []byte

func (ChanDescMsg) MsgType

func (self ChanDescMsg) MsgType() uint8

func (ChanDescMsg) Peer

func (self ChanDescMsg) Peer() uint32

type ChatMsg

type ChatMsg struct {
	PeerIdx uint32
	Text    string
}

text message

func NewChatMsg

func NewChatMsg(peerid uint32, text string) ChatMsg

func NewChatMsgFromBytes

func NewChatMsgFromBytes(b []byte, peerid uint32) (ChatMsg, error)

func (ChatMsg) Bytes

func (self ChatMsg) Bytes() []byte

func (ChatMsg) MsgType

func (self ChatMsg) MsgType() uint8

func (ChatMsg) Peer

func (self ChatMsg) Peer() uint32

type CloseReqMsg

type CloseReqMsg struct {
	PeerIdx   uint32
	Outpoint  wire.OutPoint
	Signature [64]byte
}

message for closing a channel

func NewCloseReqMsg

func NewCloseReqMsg(peerid uint32, OP wire.OutPoint, SIG [64]byte) CloseReqMsg

func NewCloseReqMsgFromBytes

func NewCloseReqMsgFromBytes(b []byte, peerid uint32) (CloseReqMsg, error)

func (CloseReqMsg) Bytes

func (self CloseReqMsg) Bytes() []byte

func (CloseReqMsg) MsgType

func (self CloseReqMsg) MsgType() uint8

func (CloseReqMsg) Peer

func (self CloseReqMsg) Peer() uint32

type CombinablePubKeySlice

type CombinablePubKeySlice []*koblitz.PublicKey

PubKeySlice are slices of pubkeys, which can be combined (and sorted)

func PubsFromArrs

func PubsFromArrs(arrSlice ...[33]byte) (CombinablePubKeySlice, error)

CombinableSliceFromArrSlice turns an array of 33 byte pubkey arrays into a CombinablePubKeySlice which can then be combined. Variadic. First time I've used that, seems appropriate here.

func (CombinablePubKeySlice) Combine

Combine combines pubkeys into one. Never errors; just returns empty pubkeys instead (which will trigger other errors because those aren't valid pubkeys) Careful to not modify the slice in place.

func (CombinablePubKeySlice) ComboCommit

func (p CombinablePubKeySlice) ComboCommit() chainhash.Hash

ComboCommit generates the "combination commitment" which contributes to the hash-coefficient for every key being combined.

func (CombinablePubKeySlice) Len

func (p CombinablePubKeySlice) Len() int

func (CombinablePubKeySlice) Less

func (p CombinablePubKeySlice) Less(i, j int) bool

func (CombinablePubKeySlice) Swap

func (p CombinablePubKeySlice) Swap(i, j int)

Make PubKeySlices sortable

type DeltaSigMsg

type DeltaSigMsg struct {
	PeerIdx   uint32
	Outpoint  wire.OutPoint
	Delta     int32
	Signature [64]byte
	Data      [32]byte
	HTLCSigs  [][64]byte
}

message for sending an amount with the signature

func NewDeltaSigMsg

func NewDeltaSigMsg(peerid uint32, OP wire.OutPoint, DELTA int32, SIG [64]byte, HTLCSigs [][64]byte, data [32]byte) DeltaSigMsg

func NewDeltaSigMsgFromBytes

func NewDeltaSigMsgFromBytes(b []byte, peerid uint32) (DeltaSigMsg, error)

func (DeltaSigMsg) Bytes

func (self DeltaSigMsg) Bytes() []byte

func (DeltaSigMsg) MsgType

func (self DeltaSigMsg) MsgType() uint8

func (DeltaSigMsg) Peer

func (self DeltaSigMsg) Peer() uint32

type DlcContract

type DlcContract struct {
	// Index of the contract for referencing in commands
	Idx uint64
	// Index of the contract on the other peer (so we can reference it in
	// messages)
	TheirIdx uint64
	// Index of the peer we've offered the contract to or received the contract
	// from
	PeerIdx uint32
	// Coin type
	CoinType uint32
	// Pub keys of the oracle and the R point used in the contract
	OracleA, OracleR [33]byte
	// The time we expect the oracle to publish
	OracleTimestamp uint64
	// The payout specification
	Division []DlcContractDivision
	// The amounts either side are funding
	OurFundingAmount, TheirFundingAmount int64
	// PKH to which the contracts funding change should go
	OurChangePKH, TheirChangePKH [20]byte
	// Pubkey used in the funding multisig output
	OurFundMultisigPub, TheirFundMultisigPub [33]byte
	// Pubkey to be used in the commit script (combined with oracle pubkey
	// or CSV timeout)
	OurPayoutBase, TheirPayoutBase [33]byte
	// Pubkeyhash to which the contract pays out (directly)
	OurPayoutPKH, TheirPayoutPKH [20]byte
	// Status of the contract
	Status DlcContractStatus
	// Outpoints used to fund the contract
	OurFundingInputs, TheirFundingInputs []DlcContractFundingInput
	// Signatures for the settlement transactions
	TheirSettlementSignatures []DlcContractSettlementSignature
	// The outpoint of the funding TX we want to spend in the settlement
	// for easier monitoring
	FundingOutpoint wire.OutPoint
}

DlcContract is a struct containing all elements to work with a Discreet Log Contract. This struct is stored in the database

func DlcContractFromBytes

func DlcContractFromBytes(b []byte) (*DlcContract, error)

DlcContractFromBytes deserializes a byte array back into a DlcContract struct

func (*DlcContract) Bytes

func (self *DlcContract) Bytes() []byte

Bytes serializes a DlcContract struct into a byte array

func (DlcContract) GetDivision

func (c DlcContract) GetDivision(value int64) (*DlcContractDivision, error)

GetDivision loops over all division specifications inside the contract and returns the one matching the requested oracle value

func (DlcContract) GetTheirSettlementSignature

func (c DlcContract) GetTheirSettlementSignature(val int64) ([64]byte, error)

GetTheirSettlementSignature loops over all stored settlement signatures from the counter party and returns the one matching the requested oracle value

type DlcContractAckMsg

type DlcContractAckMsg struct {
	// Peer we're sending the Ack to (or received it from)
	PeerIdx uint32
	// The index of the contract we're acknowledging
	Idx uint64
	// The settlement signatures of the party acknowledging
	SettlementSignatures []DlcContractSettlementSignature
}

DlcContractAckMsg is sent from the offering party back to the peer when the contract acceptance is acknowledged. Includes the signatures from this peer for the settlement TXes.

func NewDlcContractAckMsg

func NewDlcContractAckMsg(contract *DlcContract,
	signatures []DlcContractSettlementSignature) DlcContractAckMsg

NewDlcContractAckMsg generates a new DlcContractAckMsg struct based on the passed contract and signatures

func NewDlcContractAckMsgFromBytes

func NewDlcContractAckMsgFromBytes(b []byte,
	peerIdx uint32) (DlcContractAckMsg, error)

NewDlcContractAckMsgFromBytes deserializes a byte array into a DlcContractAckMsg

func (DlcContractAckMsg) Bytes

func (msg DlcContractAckMsg) Bytes() []byte

Bytes serializes a DlcContractAckMsg into a byte array

func (DlcContractAckMsg) MsgType

func (msg DlcContractAckMsg) MsgType() uint8

MsgType returns the type of this message

func (DlcContractAckMsg) Peer

func (msg DlcContractAckMsg) Peer() uint32

Peer returns the peer index this message was received from/sent to

type DlcContractDivision

type DlcContractDivision struct {
	OracleValue int64
	ValueOurs   int64
}

DlcContractDivision describes a single division of the contract. If the oracle predicts OracleValue, we receive ValueOurs

type DlcContractFundingInput

type DlcContractFundingInput struct {
	Outpoint wire.OutPoint
	Value    int64
}

DlcContractFundingInput describes a UTXO that is offered to fund the contract with

type DlcContractFundingSigsMsg

type DlcContractFundingSigsMsg struct {
	PeerIdx         uint32      // Peer we're exchanging the message with
	Idx             uint64      // The index of the concerning contract
	SignedFundingTx *wire.MsgTx // The funding TX containing the signatures
}

DlcContractFundingSigsMsg is sent by the counter party once the signatures for the settlement are verified and accepted. These signatures can be used to spend the peer's UTXOs for funding the contract into the actual contract output.

func NewDlcContractFundingSigsMsg

func NewDlcContractFundingSigsMsg(contract *DlcContract,
	signedTx *wire.MsgTx) DlcContractFundingSigsMsg

NewDlcContractFundingSigsMsg creates a new DlcContractFundingSigsMsg based on the passed contract and signed funding TX

func NewDlcContractFundingSigsMsgFromBytes

func NewDlcContractFundingSigsMsgFromBytes(b []byte,
	peerIdx uint32) (DlcContractFundingSigsMsg, error)

NewDlcContractFundingSigsMsgFromBytes deserializes a byte array into a DlcContractFundingSigsMsg

func (DlcContractFundingSigsMsg) Bytes

func (msg DlcContractFundingSigsMsg) Bytes() []byte

Bytes serializes a DlcContractFundingSigsMsg into a byte array

func (DlcContractFundingSigsMsg) MsgType

func (msg DlcContractFundingSigsMsg) MsgType() uint8

MsgType returns the type of this message

func (DlcContractFundingSigsMsg) Peer

func (msg DlcContractFundingSigsMsg) Peer() uint32

Peer returns the peer index this message was received from/sent to

type DlcContractSettlementSignature

type DlcContractSettlementSignature struct {
	// The oracle value for which transaction these are the signatures
	Outcome int64
	// The signature for the transaction
	Signature [64]byte
}

DlcContractSettlementSignature contains the signature for a particular settlement transaction

type DlcContractSigProofMsg

type DlcContractSigProofMsg struct {
	// The index of the peer we're communicating with
	PeerIdx uint32
	// The contract we're communicating about
	Idx uint64
	// The fully signed funding transaction
	SignedFundingTx *wire.MsgTx
}

DlcContractSigProofMsg acknowledges the funding of the contract to a peer. It contains the fully signed funding transaction that has already been published to the blockchain

func NewDlcContractSigProofMsg

func NewDlcContractSigProofMsg(contract *DlcContract,
	signedTx *wire.MsgTx) DlcContractSigProofMsg

NewDlcContractSigProofMsg creates a new DlcContractSigProofMsg based on the passed contract and signed funding TX

func NewDlcContractSigProofMsgFromBytes

func NewDlcContractSigProofMsgFromBytes(b []byte,
	peerIdx uint32) (DlcContractSigProofMsg, error)

NewDlcContractSigProofMsgFromBytes deserializes a byte array into a DlcContractSigProofMsg

func (DlcContractSigProofMsg) Bytes

func (msg DlcContractSigProofMsg) Bytes() []byte

Bytes serializes a DlcContractSigProofMsg into a byte array

func (DlcContractSigProofMsg) MsgType

func (msg DlcContractSigProofMsg) MsgType() uint8

MsgType returns the type of this message

func (DlcContractSigProofMsg) Peer

func (msg DlcContractSigProofMsg) Peer() uint32

Peer returns the peer index this message was received from/sent to

type DlcContractStatus

type DlcContractStatus int

DlcContractStatus is an enumeration containing the various statuses a contract can have

const (
	ContractStatusDraft        DlcContractStatus = 0
	ContractStatusOfferedByMe  DlcContractStatus = 1
	ContractStatusOfferedToMe  DlcContractStatus = 2
	ContractStatusDeclined     DlcContractStatus = 3
	ContractStatusAccepted     DlcContractStatus = 4
	ContractStatusAcknowledged DlcContractStatus = 5
	ContractStatusActive       DlcContractStatus = 6
	ContractStatusSettling     DlcContractStatus = 7
	ContractStatusClosed       DlcContractStatus = 8
	ContractStatusError        DlcContractStatus = 9
	ContractStatusAccepting    DlcContractStatus = 10
)

type DlcOfferAcceptMsg

type DlcOfferAcceptMsg struct {
	// Index of the peer we are forming the contract with
	PeerIdx uint32
	// The index of the contract on the peer we're receiving this message on
	Idx uint64
	// The index of the contract on our side, so they know how to reference it
	OurIdx uint64
	// The PKH we want the change from funding to be paid back to
	OurChangePKH [20]byte
	// The Pubkey that is part of the multisig for spending the contract funds
	OurFundMultisigPub [33]byte
	// The Pubkey to be used to in the contract settlement
	OurPayoutBase [33]byte
	// The PKH to be paid to in the contract settlement
	OurPayoutPKH [20]byte
	// The UTXOs we are using to fund the contract
	FundingInputs []DlcContractFundingInput
	// The signatures for settling the contract at various values
	SettlementSignatures []DlcContractSettlementSignature
}

DlcOfferAcceptMsg is a message indicating we are accepting the contract

func NewDlcOfferAcceptMsg

func NewDlcOfferAcceptMsg(contract *DlcContract,
	signatures []DlcContractSettlementSignature) DlcOfferAcceptMsg

NewDlcOfferAcceptMsg generates a new DlcOfferAcceptMsg struct based on the passed contract and signatures

func NewDlcOfferAcceptMsgFromBytes

func NewDlcOfferAcceptMsgFromBytes(b []byte,
	peerIdx uint32) (DlcOfferAcceptMsg, error)

NewDlcOfferAcceptMsgFromBytes parses a byte array back into a DlcOfferAcceptMsg struct

func (DlcOfferAcceptMsg) Bytes

func (msg DlcOfferAcceptMsg) Bytes() []byte

Bytes turns a DlcOfferAcceptMsg into bytes

func (DlcOfferAcceptMsg) MsgType

func (msg DlcOfferAcceptMsg) MsgType() uint8

MsgType returns the type of this message

func (DlcOfferAcceptMsg) Peer

func (msg DlcOfferAcceptMsg) Peer() uint32

Peer returns the peer index this message was received from/sent to

type DlcOfferDeclineMsg

type DlcOfferDeclineMsg struct {
	PeerIdx uint32
	Idx     uint64 // The contract we are declining
	Reason  uint8  // Reason for declining the funding request

}

func NewDlcOfferDeclineMsg

func NewDlcOfferDeclineMsg(peerIdx uint32, reason uint8,
	theirIdx uint64) DlcOfferDeclineMsg

NewDlcOfferDeclineMsg creates a new DlcOfferDeclineMsg based on a peer, a reason for declining and the index of the contract we're declining

func NewDlcOfferDeclineMsgFromBytes

func NewDlcOfferDeclineMsgFromBytes(b []byte,
	peerIdx uint32) (DlcOfferDeclineMsg, error)

NewDlcOfferDeclineMsgFromBytes deserializes a byte array into a DlcOfferDeclineMsg

func (DlcOfferDeclineMsg) Bytes

func (msg DlcOfferDeclineMsg) Bytes() []byte

Bytes serializes a DlcOfferDeclineMsg into a byte array

func (DlcOfferDeclineMsg) MsgType

func (msg DlcOfferDeclineMsg) MsgType() uint8

MsgType returns the type of this message

func (DlcOfferDeclineMsg) Peer

func (msg DlcOfferDeclineMsg) Peer() uint32

Peer returns the peer index this message was received from/sent to

type DlcOfferMsg

type DlcOfferMsg struct {
	PeerIdx  uint32
	Contract *DlcContract
}

DlcOfferMsg is the message we send to a peer to offer that peer a particular contract

func NewDlcOfferMsg

func NewDlcOfferMsg(peerIdx uint32, contract *DlcContract) DlcOfferMsg

NewDlcOfferMsg creates a new DlcOfferMsg based on a peer and contract

func NewDlcOfferMsgFromBytes

func NewDlcOfferMsgFromBytes(b []byte, peerIDX uint32) (DlcOfferMsg, error)

NewDlcOfferMsgFromBytes parses a byte array back into a DlcOfferMsg

func (DlcOfferMsg) Bytes

func (msg DlcOfferMsg) Bytes() []byte

Bytes serializes a DlcOfferMsg into a byte array

func (DlcOfferMsg) MsgType

func (msg DlcOfferMsg) MsgType() uint8

MsgType returns the type of this message

func (DlcOfferMsg) Peer

func (msg DlcOfferMsg) Peer() uint32

Peer returns the peer index this message was received from/sent to

type DualFundingAcceptMsg

type DualFundingAcceptMsg struct {
	PeerIdx             uint32
	CoinType            uint32 // Cointype we are funding
	OurPub              [33]byte
	OurRefundPub        [33]byte
	OurHAKDBase         [33]byte
	OurChangeAddressPKH [20]byte // The address we want to receive change for funding
	OurNextHTLCBase     [33]byte
	OurN2HTLCBase       [33]byte
	OurInputs           []DualFundingInput // The inputs we will use for funding
}

func NewDualFundingAcceptMsg

func NewDualFundingAcceptMsg(peerIdx uint32, coinType uint32, ourPub [33]byte, ourRefundPub [33]byte, ourHAKDBase [33]byte, ourChangeAddress [20]byte, ourInputs []DualFundingInput, ourNextHTLCBase [33]byte, ourN2HTLCBase [33]byte) DualFundingAcceptMsg

func NewDualFundingAcceptMsgFromBytes

func NewDualFundingAcceptMsgFromBytes(b []byte, peerIdx uint32) (DualFundingAcceptMsg, error)

func (DualFundingAcceptMsg) Bytes

func (self DualFundingAcceptMsg) Bytes() []byte

ToBytes turns a DualFundingReqMsg into bytes

func (DualFundingAcceptMsg) MsgType

func (self DualFundingAcceptMsg) MsgType() uint8

func (DualFundingAcceptMsg) Peer

func (self DualFundingAcceptMsg) Peer() uint32

type DualFundingChanAckMsg

type DualFundingChanAckMsg struct {
	PeerIdx         uint32
	Outpoint        wire.OutPoint
	ElkZero         [33]byte
	ElkOne          [33]byte
	ElkTwo          [33]byte
	Signature       [64]byte
	SignedFundingTx *wire.MsgTx
}

message for channel acknowledgement and funding signatures

func NewDualFundingChanAckMsg

func NewDualFundingChanAckMsg(peerid uint32, OP wire.OutPoint, ELKZero [33]byte, ELKOne [33]byte, ELKTwo [33]byte, SIG [64]byte, signedFundingTx *wire.MsgTx) DualFundingChanAckMsg

func NewDualFundingChanAckMsgFromBytes

func NewDualFundingChanAckMsgFromBytes(b []byte, peerid uint32) (DualFundingChanAckMsg, error)

func (DualFundingChanAckMsg) Bytes

func (self DualFundingChanAckMsg) Bytes() []byte

func (DualFundingChanAckMsg) MsgType

func (self DualFundingChanAckMsg) MsgType() uint8

func (DualFundingChanAckMsg) Peer

func (self DualFundingChanAckMsg) Peer() uint32

type DualFundingDeclMsg

type DualFundingDeclMsg struct {
	PeerIdx uint32
	Reason  uint8 // Reason for declining the funding request
}

func NewDualFundingDeclMsg

func NewDualFundingDeclMsg(peerIdx uint32, reason uint8) DualFundingDeclMsg

func NewDualFundingDeclMsgFromBytes

func NewDualFundingDeclMsgFromBytes(b []byte, peerIdx uint32) (DualFundingDeclMsg, error)

func (DualFundingDeclMsg) Bytes

func (self DualFundingDeclMsg) Bytes() []byte

ToBytes turns a DualFundingReqMsg into bytes

func (DualFundingDeclMsg) MsgType

func (self DualFundingDeclMsg) MsgType() uint8

func (DualFundingDeclMsg) Peer

func (self DualFundingDeclMsg) Peer() uint32

type DualFundingInput

type DualFundingInput struct {
	Outpoint wire.OutPoint
	Value    int64
}

type DualFundingReqMsg

type DualFundingReqMsg struct {
	PeerIdx             uint32
	CoinType            uint32 // Cointype we are funding
	OurAmount           int64  // The amount we are funding
	TheirAmount         int64  // The amount we are requesting the counterparty to fund
	OurPub              [33]byte
	OurRefundPub        [33]byte
	OurHAKDBase         [33]byte
	OurChangeAddressPKH [20]byte           // The address we want to receive change for funding
	OurInputs           []DualFundingInput // The inputs we will use for funding
}

func NewDualFundingReqMsg

func NewDualFundingReqMsg(peerIdx, cointype uint32, ourAmount int64, theirAmount int64, ourPub [33]byte, ourRefundPub [33]byte, ourHAKDBase [33]byte, ourChangeAddressPKH [20]byte, ourInputs []DualFundingInput) DualFundingReqMsg

func NewDualFundingReqMsgFromBytes

func NewDualFundingReqMsgFromBytes(b []byte, peerIdx uint32) (DualFundingReqMsg, error)

func (DualFundingReqMsg) Bytes

func (self DualFundingReqMsg) Bytes() []byte

ToBytes turns a DualFundingReqMsg into bytes

func (DualFundingReqMsg) MsgType

func (self DualFundingReqMsg) MsgType() uint8

func (DualFundingReqMsg) Peer

func (self DualFundingReqMsg) Peer() uint32

type GapSigRevMsg

type GapSigRevMsg struct {
	PeerIdx    uint32
	Outpoint   wire.OutPoint
	Signature  [64]byte
	Elk        chainhash.Hash
	N2ElkPoint [33]byte
	N2HTLCBase [33]byte
	HTLCSigs   [][64]byte
}

message for signaling state has moved, revoking old state

func NewGapSigRev

func NewGapSigRev(peerid uint32, OP wire.OutPoint, SIG [64]byte, ELK chainhash.Hash, N2ELK [33]byte, HTLCSigs [][64]byte, N2HTLCBase [33]byte) GapSigRevMsg

func NewGapSigRevFromBytes

func NewGapSigRevFromBytes(b []byte, peerId uint32) (GapSigRevMsg, error)

func (GapSigRevMsg) Bytes

func (self GapSigRevMsg) Bytes() []byte

func (GapSigRevMsg) MsgType

func (self GapSigRevMsg) MsgType() uint8

func (GapSigRevMsg) Peer

func (self GapSigRevMsg) Peer() uint32

type HashSigMsg

type HashSigMsg struct {
	PeerIdx  uint32
	Outpoint wire.OutPoint

	Amt      int64
	Locktime uint32
	RHash    [32]byte

	Data [32]byte

	CommitmentSignature [64]byte
	// must be at least 36 + 4 + 32 + 33 + 32 + 64 = 169 bytes
	HTLCSigs [][64]byte
}

message for offering an HTLC

func NewHashSigMsg

func NewHashSigMsg(peerid uint32, OP wire.OutPoint, amt int64, locktime uint32, RHash [32]byte, sig [64]byte, HTLCSigs [][64]byte, data [32]byte) HashSigMsg

func NewHashSigMsgFromBytes

func NewHashSigMsgFromBytes(b []byte, peerid uint32) (HashSigMsg, error)

func (HashSigMsg) Bytes

func (self HashSigMsg) Bytes() []byte

func (HashSigMsg) MsgType

func (self HashSigMsg) MsgType() uint8

func (HashSigMsg) Peer

func (self HashSigMsg) Peer() uint32

type HeightEvent

type HeightEvent struct {
	Height   int32
	CoinType uint32
}

HeightEvent is to inform the LN node of a new blockheight on a particular coin type. Used to detect and enforce HTLC timeouts

type LinkMsg

type LinkMsg struct {
	PeerIdx   uint32
	APKH      [20]byte // APKH (A's LN address)
	ACapacity int64    // ACapacity (A's channel balance)
	BPKH      [20]byte // BPKH (B's LN address)
	CoinType  uint32   // CoinType (Network of the channel)
	Seq       uint32   // seq (Link state sequence #)
	Timestamp int64
	Rates     []RateDesc
}

func NewLinkMsgFromBytes

func NewLinkMsgFromBytes(b []byte, peerIDX uint32) (LinkMsg, error)

func (LinkMsg) Bytes

func (self LinkMsg) Bytes() []byte

ToBytes turns a LinkMsg into 88 bytes

func (LinkMsg) MsgType

func (self LinkMsg) MsgType() uint8

func (LinkMsg) Peer

func (self LinkMsg) Peer() uint32

type LitMsg

type LitMsg interface {
	Peer() uint32   //return PeerIdx
	MsgType() uint8 //returns Message Type (see constants above)
	Bytes() []byte  //returns data of message as []byte with the MsgType() preceding it
}

interface that all messages follow, for easy use

func LitMsgFromBytes

func LitMsgFromBytes(b []byte, peerid uint32) (LitMsg, error)

method for finding what type of message a generic []byte is

type MultihopPaymentAckMsg

type MultihopPaymentAckMsg struct {
	// The index of the peer we're communicating with
	PeerIdx uint32
	// The hash to the preimage we use to clear out the HTLCs
	HHash [32]byte
}

MultihopPaymentRequestMsg initiates a new multihop payment. It is sent to the peer that will ultimately send the payment.

func NewMultihopPaymentAckMsg

func NewMultihopPaymentAckMsg(peerIdx uint32, hHash [32]byte) MultihopPaymentAckMsg

func NewMultihopPaymentAckMsgFromBytes

func NewMultihopPaymentAckMsgFromBytes(b []byte,
	peerIdx uint32) (MultihopPaymentAckMsg, error)

func (MultihopPaymentAckMsg) Bytes

func (msg MultihopPaymentAckMsg) Bytes() []byte

Bytes serializes a MultihopPaymentAckMsg into a byte array

func (MultihopPaymentAckMsg) MsgType

func (msg MultihopPaymentAckMsg) MsgType() uint8

MsgType returns the type of this message

func (MultihopPaymentAckMsg) Peer

func (msg MultihopPaymentAckMsg) Peer() uint32

type MultihopPaymentRequestMsg

type MultihopPaymentRequestMsg struct {
	// The index of the peer we're communicating with
	PeerIdx uint32
	// The type of coin we're requesting to send
	Cointype uint32
}

MultihopPaymentRequestMsg initiates a new multihop payment. It is sent to the peer that will ultimately receive the payment.

func NewMultihopPaymentRequestMsg

func NewMultihopPaymentRequestMsg(peerIdx uint32, cointype uint32) MultihopPaymentRequestMsg

func NewMultihopPaymentRequestMsgFromBytes

func NewMultihopPaymentRequestMsgFromBytes(b []byte,
	peerIdx uint32) (MultihopPaymentRequestMsg, error)

func (MultihopPaymentRequestMsg) Bytes

func (msg MultihopPaymentRequestMsg) Bytes() []byte

Bytes serializes a MultihopPaymentRequestMsg into a byte array

func (MultihopPaymentRequestMsg) MsgType

func (msg MultihopPaymentRequestMsg) MsgType() uint8

MsgType returns the type of this message

func (MultihopPaymentRequestMsg) Peer

func (msg MultihopPaymentRequestMsg) Peer() uint32

Peer returns the peer index this message was received from/sent to

type MultihopPaymentSetupMsg

type MultihopPaymentSetupMsg struct {
	// The index of the peer we're communicating with
	PeerIdx uint32
	// The hash to the preimage we use to clear out the HTLCs
	HHash [32]byte
	// The PKHs (in order) of the nodes we're using.
	NodeRoute []RouteHop
	// Data associated with the payment
	Data [32]byte
}

MultihopPaymentSetupMsg forms a new multihop payment. It is sent to the next-in-line peer, which will forward it to the next hop until the target is reached

func NewMultihopPaymentSetupMsg

func NewMultihopPaymentSetupMsg(peerIdx uint32, hHash [32]byte, nodeRoute []RouteHop, data [32]byte) MultihopPaymentSetupMsg

NewMultihopPaymentSetupMsg does...

func NewMultihopPaymentSetupMsgFromBytes

func NewMultihopPaymentSetupMsgFromBytes(b []byte,
	peerIdx uint32) (MultihopPaymentSetupMsg, error)

func (MultihopPaymentSetupMsg) Bytes

func (msg MultihopPaymentSetupMsg) Bytes() []byte

Bytes serializes a MultihopPaymentSetupMsg into a byte array

func (MultihopPaymentSetupMsg) MsgType

func (msg MultihopPaymentSetupMsg) MsgType() uint8

MsgType returns the type of this message

func (MultihopPaymentSetupMsg) Peer

func (msg MultihopPaymentSetupMsg) Peer() uint32

type OutPointEvent

type OutPointEvent struct {
	Op     wire.OutPoint // the outpoint being described
	Height int32         // the height of the event
	Tx     *wire.MsgTx   // the tx spending the outpoint
}

OutPointEvent is a message describing events concerning an outpoint. There's 2 event types: confirmation and spend. If the Tx pointer is nil, then it's a confirm. If the Tx has an actual MsgTx in there, it's a spend. The Height refers to either the confirmation height or the height at which it was spent. (0 means seen but unconfirmed)

type PointReqMsg

type PointReqMsg struct {
	PeerIdx  uint32
	Cointype uint32
}

message with no information, just shows a point is requested

func NewPointReqMsg

func NewPointReqMsg(peerid uint32, cointype uint32) PointReqMsg

func NewPointReqMsgFromBytes

func NewPointReqMsgFromBytes(b []byte, peerid uint32) (PointReqMsg, error)

func (PointReqMsg) Bytes

func (self PointReqMsg) Bytes() []byte

func (PointReqMsg) MsgType

func (self PointReqMsg) MsgType() uint8

func (PointReqMsg) Peer

func (self PointReqMsg) Peer() uint32

type PointRespMsg

type PointRespMsg struct {
	PeerIdx    uint32
	ChannelPub [33]byte
	RefundPub  [33]byte
	HAKDbase   [33]byte

	NextHTLCBase [33]byte
	N2HTLCBase   [33]byte
}

message to be used for reply to point request

func NewPointRespMsg

func NewPointRespMsg(peerid uint32, chanpub [33]byte, refundpub [33]byte,
	HAKD [33]byte, nextHTLCBase [33]byte, N2HTLCBase [33]byte) PointRespMsg

func NewPointRespMsgFromBytes

func NewPointRespMsgFromBytes(b []byte, peerid uint32) (PointRespMsg, error)

NewPointRespMsgFromBytes takes a byte slice and a peerid and constructs a PointRespMsg object from the bytes. Expects at least 1 + 33 + 33 + 33 + 33 + 33 = 166.

func (PointRespMsg) Bytes

func (self PointRespMsg) Bytes() []byte

func (PointRespMsg) MsgType

func (self PointRespMsg) MsgType() uint8

func (PointRespMsg) Peer

func (self PointRespMsg) Peer() uint32

type PreimageSigMsg

type PreimageSigMsg struct {
	PeerIdx  uint32
	Outpoint wire.OutPoint

	Idx uint32
	R   [16]byte

	Data [32]byte

	CommitmentSignature [64]byte
	// must be at least 36 + 4 + 16 + 32 + 64 = 152 bytes
	HTLCSigs [][64]byte
}

message for clearing an HTLC

func NewPreimageSigMsg

func NewPreimageSigMsg(peerid uint32, OP wire.OutPoint, Idx uint32, R [16]byte, sig [64]byte, HTLCSigs [][64]byte, data [32]byte) PreimageSigMsg

func NewPreimageSigMsgFromBytes

func NewPreimageSigMsgFromBytes(b []byte, peerid uint32) (PreimageSigMsg, error)

func (PreimageSigMsg) Bytes

func (self PreimageSigMsg) Bytes() []byte

func (PreimageSigMsg) MsgType

func (self PreimageSigMsg) MsgType() uint8

func (PreimageSigMsg) Peer

func (self PreimageSigMsg) Peer() uint32

type RateDesc

type RateDesc struct {
	CoinType   uint32
	Rate       int64
	Reciprocal bool
}

To find how much 1 satoshi of coin type A will cost you in coin type B, if Reciprocal is false, 1 satoshi of A will buy you `rate` satoshis of B. Otherwise, 1 satoshi of B will buy you `rate` satoshis of A. This avoids the use of floating point for deciding price.

func NewRateDescFromBytes

func NewRateDescFromBytes(b []byte) (RateDesc, error)

func (*RateDesc) Bytes

func (rd *RateDesc) Bytes() []byte

type RemoteControlRpcRequestMsg

type RemoteControlRpcRequestMsg struct {
	PeerIdx uint32
	// The pubkey of the node remote controlling. Can be null, in which case
	// the pubkey of the peer sending the message is used to determine the
	// authorization
	PubKey [33]byte

	// The method being called, for example "LitRPC.Send"
	Method string

	// A unique nonce that will be used to match the response that is sent
	// back in reply to this request.
	Idx uint64

	// The JSON serialized arguments to the RPC method
	Args []byte

	// If PubKey is passed, this should contain a signature made with the
	// corresponding private key of the Bytes() method of this message type,
	// containing a zero Sig
	Sig [64]byte

	// The digest used for the signature. Can be one of
	// DIGEST_TYPE_SHA256    = 0x00 (Default)
	// DIGEST_TYPE_RIPEMD160 = 0x01
	// Different digest is supported to allow the use of embedded devices
	// such as smart cards that do not support signing SHA256 digests.
	// They exist, really.
	DigestType uint8
}

RemoteControlRpcRequestMsg contains a request to be executed by the local lit node, when the remote node has been authorized to do so.

func NewRemoteControlRpcRequestMsgFromBytes

func NewRemoteControlRpcRequestMsgFromBytes(b []byte,
	peerIdx uint32) (RemoteControlRpcRequestMsg, error)

func (RemoteControlRpcRequestMsg) Bytes

func (msg RemoteControlRpcRequestMsg) Bytes() []byte

Bytes serializes a RemoteControlRpcRequestMsg into a byte array

func (RemoteControlRpcRequestMsg) MsgType

func (msg RemoteControlRpcRequestMsg) MsgType() uint8

func (RemoteControlRpcRequestMsg) Peer

Peer returns the peer index this message was received from/sent to

type RemoteControlRpcResponseMsg

type RemoteControlRpcResponseMsg struct {
	PeerIdx uint32
	Idx     uint64 // Unique nonce that was sent in the request
	Error   bool   // Indicates that the reply is an error
	Result  []byte // JSON serialization of the reply object
}

RemoteControlRpcResponseMsg is sent in response to a request message and contains the output of the command that was executed

func NewRemoteControlRpcResponseMsg

func NewRemoteControlRpcResponseMsg(peerIdx uint32, msgIdx uint64, isError bool, json []byte) RemoteControlRpcResponseMsg

func NewRemoteControlRpcResponseMsgFromBytes

func NewRemoteControlRpcResponseMsgFromBytes(b []byte,
	peerIdx uint32) (RemoteControlRpcResponseMsg, error)

func (RemoteControlRpcResponseMsg) Bytes

func (msg RemoteControlRpcResponseMsg) Bytes() []byte

Bytes serializes a RemoteControlRpcRequestMsg into a byte array

func (RemoteControlRpcResponseMsg) MsgType

func (msg RemoteControlRpcResponseMsg) MsgType() uint8

MsgType returns the type of this message

func (RemoteControlRpcResponseMsg) Peer

Peer returns the peer index this message was received from/sent to

type RevMsg

type RevMsg struct {
	PeerIdx    uint32
	Outpoint   wire.OutPoint
	Elk        chainhash.Hash
	N2ElkPoint [33]byte
	N2HTLCBase [33]byte
}

send message across channel using Elk info

func NewRevMsg

func NewRevMsg(peerid uint32, OP wire.OutPoint, ELK chainhash.Hash, N2ELK [33]byte, N2HTLCBase [33]byte) RevMsg

func NewRevMsgFromBytes

func NewRevMsgFromBytes(b []byte, peerId uint32) (RevMsg, error)

func (RevMsg) Bytes

func (self RevMsg) Bytes() []byte

func (RevMsg) MsgType

func (self RevMsg) MsgType() uint8

func (RevMsg) Peer

func (self RevMsg) Peer() uint32

type RouteHop

type RouteHop struct {
	Node     [20]byte
	CoinType uint32
}

func NewRouteHopFromBytes

func NewRouteHopFromBytes(b []byte) (*RouteHop, error)

func (*RouteHop) Bytes

func (rh *RouteHop) Bytes() []byte

type SigProofMsg

type SigProofMsg struct {
	PeerIdx   uint32
	Outpoint  wire.OutPoint
	Signature [64]byte
}

message for proof for a signature

func NewSigProofMsg

func NewSigProofMsg(peerid uint32, OP wire.OutPoint, SIG [64]byte) SigProofMsg

func NewSigProofMsgFromBytes

func NewSigProofMsgFromBytes(b []byte, peerid uint32) (SigProofMsg, error)

func (SigProofMsg) Bytes

func (self SigProofMsg) Bytes() []byte

func (SigProofMsg) MsgType

func (self SigProofMsg) MsgType() uint8

func (SigProofMsg) Peer

func (self SigProofMsg) Peer() uint32

type SigRevMsg

type SigRevMsg struct {
	PeerIdx    uint32
	Outpoint   wire.OutPoint
	Signature  [64]byte
	Elk        chainhash.Hash
	N2ElkPoint [33]byte
	HTLCSigs   [][64]byte
	N2HTLCBase [33]byte
}

a message that pushes using channel information

func NewSigRev

func NewSigRev(peerid uint32, OP wire.OutPoint, SIG [64]byte, ELK chainhash.Hash,
	N2ELK [33]byte, HTLCSigs [][64]byte, N2HTLCBase [33]byte) SigRevMsg

func NewSigRevFromBytes

func NewSigRevFromBytes(b []byte, peerid uint32) (SigRevMsg, error)

func (SigRevMsg) Bytes

func (self SigRevMsg) Bytes() []byte

func (SigRevMsg) MsgType

func (self SigRevMsg) MsgType() uint8

func (SigRevMsg) Peer

func (self SigRevMsg) Peer() uint32

type TxAndHeight

type TxAndHeight struct {
	Tx     *wire.MsgTx
	Height int32
}

TxAndHeight is just a tx, and the height at which it was confirmed.

type WatchDelMsg

type WatchDelMsg struct {
	PeerIdx  uint32
	DestPKH  [20]byte // identifier for channel; could be optimized away
	RevealPK [33]byte // reveal this pubkey, matches DestPKH

}

func NewWatchDelMsgFromBytes

func NewWatchDelMsgFromBytes(b []byte, peerIDX uint32) (WatchDelMsg, error)

ComMsgFromBytes turns 132 bytes into a SourceMsg Silently fails with wrong size input.

func (WatchDelMsg) Bytes

func (self WatchDelMsg) Bytes() []byte

Bytes turns a ComMsg into 132 bytes

func (WatchDelMsg) MsgType

func (self WatchDelMsg) MsgType() uint8

func (WatchDelMsg) Peer

func (self WatchDelMsg) Peer() uint32

type WatchDescMsg

type WatchDescMsg struct {
	PeerIdx       uint32
	CoinType      uint32   // what network this channel is on
	DestPKHScript [20]byte // PKH to grab to; main unique identifier.

	Delay uint16 // timeout in blocks
	Fee   int64  // fee to use for grab tx.  Or fee rate...?

	CustomerBasePoint  [33]byte // client's HAKD key base point
	AdversaryBasePoint [33]byte // potential attacker's timeout basepoint
}

WatchannelDescriptor is the initial message setting up a Watchannel

func NewWatchDescMsg

func NewWatchDescMsg(
	peeridx, coinType uint32, destScript [20]byte,
	delay uint16, fee int64, customerBase [33]byte,
	adversaryBase [33]byte) WatchDescMsg

NewWatchDescMsg turns 96 bytes into a WatchannelDescriptor Silently fails with incorrect size input, watch out.

func NewWatchDescMsgFromBytes

func NewWatchDescMsgFromBytes(b []byte, peerIDX uint32) (WatchDescMsg, error)

func (WatchDescMsg) Bytes

func (self WatchDescMsg) Bytes() []byte

Bytes turns a WatchannelDescriptor into 100 bytes

func (WatchDescMsg) MsgType

func (self WatchDescMsg) MsgType() uint8

func (WatchDescMsg) Peer

func (self WatchDescMsg) Peer() uint32

type WatchStateMsg

type WatchStateMsg struct {
	PeerIdx  uint32
	CoinType uint32         // could figure it out from PKH but this is easier
	DestPKH  [20]byte       // identifier for channel; could be optimized away
	Elk      chainhash.Hash // elkrem for this state index
	ParTxid  [16]byte       // 16 bytes of txid
	Sig      [64]byte       // 64 bytes of sig
}

ComMsg are 137 bytes. msgtype CoinType 4 PKH 20 txid 16 sig 64 elk 32

func NewComMsg

func NewComMsg(peerIdx, cointype uint32, destPKH [20]byte,
	elk chainhash.Hash, parTxid [16]byte, sig [64]byte) WatchStateMsg

func NewWatchStateMsgFromBytes

func NewWatchStateMsgFromBytes(b []byte, peerIDX uint32) (WatchStateMsg, error)

ComMsgFromBytes turns 132 bytes into a SourceMsg Silently fails with wrong size input.

func (WatchStateMsg) Bytes

func (self WatchStateMsg) Bytes() []byte

ToBytes turns a ComMsg into 132 bytes

func (WatchStateMsg) MsgType

func (self WatchStateMsg) MsgType() uint8

func (WatchStateMsg) Peer

func (self WatchStateMsg) Peer() uint32

Jump to

Keyboard shortcuts

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