mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 12:14:21 +01:00
* [domain] add reverse boarding inputs in Payment struct * [tx-builder] support reverse boarding script * [wallet] add GetTransaction * [api-spec][application] add reverse boarding support in covenantless * [config] add reverse boarding config * [api-spec] add ReverseBoardingAddress RPC * [domain][application] support empty forfeits txs in EndFinalization events * [tx-builder] optional connector output in round tx * [btc-embedded] fix getTx and taproot finalizer * whitelist ReverseBoardingAddress RPC * [test] add reverse boarding integration test * [client] support reverse boarding * [sdk] support reverse boarding * [e2e] add sleep time after faucet * [test] run using bitcoin-core RPC * [tx-builder] fix GetSweepInput * [application][tx-builder] support reverse onboarding in covenant * [cli] support reverse onboarding in covenant CLI * [test] rework integration tests * [sdk] remove onchain wallet, replace by onboarding address * remove old onboarding protocols * [sdk] Fix RegisterPayment * [e2e] add more funds to covenant ASP * [e2e] add sleeping time * several fixes * descriptor boarding * remove boarding delay from info * [sdk] implement descriptor boarding * go mod tidy * fixes and revert error msgs * move descriptor pkg to common * add replace in go.mod * [sdk] fix unit tests * rename DescriptorInput --> BoardingInput * genrest in SDK * remove boarding input from domain * remove all "reverse boarding" * rename "onboarding" ==> "boarding" * remove outdate payment unit test * use tmpfs docker volument for compose testing files * several fixes
192 lines
4.0 KiB
Go
192 lines
4.0 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/ark-network/ark/common/bitcointree"
|
|
"github.com/ark-network/ark/common/tree"
|
|
"github.com/decred/dcrd/dcrec/secp256k1/v4"
|
|
)
|
|
|
|
const (
|
|
GrpcClient = "grpc"
|
|
RestClient = "rest"
|
|
)
|
|
|
|
type RoundEvent interface {
|
|
isRoundEvent()
|
|
}
|
|
|
|
type ASPClient interface {
|
|
GetInfo(ctx context.Context) (*Info, error)
|
|
ListVtxos(ctx context.Context, addr string) ([]Vtxo, []Vtxo, error)
|
|
GetRound(ctx context.Context, txID string) (*Round, error)
|
|
GetRoundByID(ctx context.Context, roundID string) (*Round, error)
|
|
RegisterPayment(
|
|
ctx context.Context, inputs []Input, ephemeralKey string,
|
|
) (string, error)
|
|
ClaimPayment(
|
|
ctx context.Context, paymentID string, outputs []Output,
|
|
) error
|
|
GetEventStream(
|
|
ctx context.Context, paymentID string,
|
|
) (<-chan RoundEventChannel, error)
|
|
Ping(ctx context.Context, paymentID string) (RoundEvent, error)
|
|
FinalizePayment(
|
|
ctx context.Context, signedForfeitTxs []string, signedRoundTx string,
|
|
) error
|
|
CreatePayment(
|
|
ctx context.Context, inputs []VtxoKey, outputs []Output,
|
|
) (string, []string, error)
|
|
CompletePayment(
|
|
ctx context.Context, signedRedeemTx string, signedUnconditionalForfeitTxs []string,
|
|
) error
|
|
GetBoardingAddress(ctx context.Context, userPubkey string) (string, error)
|
|
SendTreeNonces(
|
|
ctx context.Context, roundID, cosignerPubkey string, nonces bitcointree.TreeNonces,
|
|
) error
|
|
SendTreeSignatures(
|
|
ctx context.Context, roundID, cosignerPubkey string, signatures bitcointree.TreePartialSigs,
|
|
) error
|
|
Close()
|
|
}
|
|
|
|
type Info struct {
|
|
Pubkey string
|
|
RoundLifetime int64
|
|
UnilateralExitDelay int64
|
|
RoundInterval int64
|
|
Network string
|
|
MinRelayFee int64
|
|
BoardingDescriptorTemplate string
|
|
}
|
|
|
|
type RoundEventChannel struct {
|
|
Event RoundEvent
|
|
Err error
|
|
}
|
|
|
|
type Input interface {
|
|
GetTxID() string
|
|
GetVOut() uint32
|
|
GetDescriptor() string
|
|
}
|
|
|
|
type VtxoKey struct {
|
|
Txid string
|
|
VOut uint32
|
|
}
|
|
|
|
func (k VtxoKey) GetTxID() string {
|
|
return k.Txid
|
|
}
|
|
|
|
func (k VtxoKey) GetVOut() uint32 {
|
|
return k.VOut
|
|
}
|
|
|
|
func (k VtxoKey) GetDescriptor() string {
|
|
return ""
|
|
}
|
|
|
|
type BoardingInput struct {
|
|
VtxoKey
|
|
Descriptor string
|
|
}
|
|
|
|
func (k BoardingInput) GetDescriptor() string {
|
|
return k.Descriptor
|
|
}
|
|
|
|
type Vtxo struct {
|
|
VtxoKey
|
|
Amount uint64
|
|
RoundTxid string
|
|
ExpiresAt *time.Time
|
|
RedeemTx string
|
|
UnconditionalForfeitTxs []string
|
|
Pending bool
|
|
SpentBy string
|
|
}
|
|
|
|
type Output struct {
|
|
Address string
|
|
Amount uint64
|
|
}
|
|
|
|
type RoundStage int
|
|
|
|
func (s RoundStage) String() string {
|
|
switch s {
|
|
case RoundStageRegistration:
|
|
return "ROUND_STAGE_REGISTRATION"
|
|
case RoundStageFinalization:
|
|
return "ROUND_STAGE_FINALIZATION"
|
|
case RoundStageFinalized:
|
|
return "ROUND_STAGE_FINALIZED"
|
|
case RoundStageFailed:
|
|
return "ROUND_STAGE_FAILED"
|
|
default:
|
|
return "ROUND_STAGE_UNDEFINED"
|
|
}
|
|
}
|
|
|
|
const (
|
|
RoundStageUndefined RoundStage = iota
|
|
RoundStageRegistration
|
|
RoundStageFinalization
|
|
RoundStageFinalized
|
|
RoundStageFailed
|
|
)
|
|
|
|
type Round struct {
|
|
ID string
|
|
StartedAt *time.Time
|
|
EndedAt *time.Time
|
|
Tx string
|
|
Tree tree.CongestionTree
|
|
ForfeitTxs []string
|
|
Connectors []string
|
|
Stage RoundStage
|
|
}
|
|
|
|
type RoundFinalizationEvent struct {
|
|
ID string
|
|
Tx string
|
|
ForfeitTxs []string
|
|
Tree tree.CongestionTree
|
|
Connectors []string
|
|
}
|
|
|
|
func (e RoundFinalizationEvent) isRoundEvent() {}
|
|
|
|
type RoundFinalizedEvent struct {
|
|
ID string
|
|
Txid string
|
|
}
|
|
|
|
func (e RoundFinalizedEvent) isRoundEvent() {}
|
|
|
|
type RoundFailedEvent struct {
|
|
ID string
|
|
Reason string
|
|
}
|
|
|
|
func (e RoundFailedEvent) isRoundEvent() {}
|
|
|
|
type RoundSigningStartedEvent struct {
|
|
ID string
|
|
UnsignedTree tree.CongestionTree
|
|
CosignersPublicKeys []*secp256k1.PublicKey
|
|
}
|
|
|
|
func (e RoundSigningStartedEvent) isRoundEvent() {}
|
|
|
|
type RoundSigningNoncesGeneratedEvent struct {
|
|
ID string
|
|
Nonces bitcointree.TreeNonces
|
|
}
|
|
|
|
func (e RoundSigningNoncesGeneratedEvent) isRoundEvent() {}
|