Add support for covenant-less ASP (#214)

* scaffolding wallet

* remove wallet db, add loader instead

* wip

* implement some wallet methods

* signing and utxos

* renaming

* fee estimator

* chain source options

* config

* application service

* clark docker-compose

* CLI refactor

* v0 clark

* v0.1 clark

* fix SignTapscriptInput (btcwallet)

* wallet.Broadcast, send via explora

* fix ASP pubkey

* Use lnd's btcwallet & Add rpc to get wallet staus

* wip

* unilateral exit

* Fixes on watching for notifications and cli init

* handle non-final BIP68 errors

* Fixes

* Fixes

* Fix

* a

* fix onboard cosigners + revert tree validation

* fix covenant e2e tests

* fix covenantless e2e tests

* fix container naming

* fix lint error

* update REAME.md

* Add env var for wallet password

---------

Co-authored-by: altafan <18440657+altafan@users.noreply.github.com>
This commit is contained in:
Louis Singer
2024-07-30 20:57:52 +02:00
committed by GitHub
parent 89df461623
commit 01297ae38c
99 changed files with 9487 additions and 2704 deletions

View File

@@ -13,16 +13,50 @@ In this repository you can find:
Refer to the README in each directory for more information about development.
## Build and Run with Docker
## Run the Ark Service Provider
| | Covenant-less | Covenant |
|---------|------------------------|----------------------------------------|
| Network | Bitcoin (regtest only)<br/>⚠️ *Mainnet & Testnet coming soon* | Liquid, Liquid testnet, Liquid regtest |
| Wallet | Embedded [lnwallet](https://pkg.go.dev/github.com/lightningnetwork/lnd/lnwallet/btcwallet) in `arkd` | [Ocean](https://github.com/vulpemventures/ocean) wallet |
> The covenant version of Ark requires [special tapscript opcodes](https://github.com/ElementsProject/elements/blob/master/doc/tapscript_opcodes.md) only available on Liquid Network.
### Covenant-less Ark
#### Run the daemon (regtest)
Run locally with [Docker](https://docs.docker.com/engine/install/) and [Nigiri](https://nigiri.vulpem.com/).
```
nigiri start
docker compose -f ./docker-compose.clark.regtest.yml up -d
```
the compose file will start a `clarkd` container exposing Ark API on localhost:6000.
#### Fund the embedded wallet
The ASP needs funds to operate. the `v1/admin/address` allows to generate a new address. This endpoint is protected by Basic Authorization token.
```
curl http://localhost:6000/v1/admin/address -H 'Authorization: Basic YWRtaW46YWRtaW4='
```
> This exemple is using the default USER/PASSWORD credentials. You can customize them by setting the `ARK_AUTH_USER` and `ARK_AUTH_PASS` variables.
Faucet the address using nigiri
```
nigiri faucet <ASP_address>
```
### Ark with covenants (Liquid only)
#### Setup the Ocean wallet
Run locally with Docker on Liquid Testnet. It uses `docker-compose` to build the `arkd` docker image from `server` and run the it as container, together with the `oceand` container.
### Prerequisites
- [Docker](https://docs.docker.com/engine/install/)
### Setup the Ocean wallet
Start `oceand` in Liquid Testnet:
```bash
@@ -38,7 +72,7 @@ ocean wallet create --password <password>
ocean wallet unlock --password <password>
```
### Run arkd connected to Ocean
#### Run `arkd` connected to Ocean
Start the ASP

View File

@@ -1,117 +0,0 @@
package main
import (
"fmt"
"strings"
"time"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/urfave/cli/v2"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)
type vtxo struct {
amount uint64
txid string
vout uint32
poolTxid string
expireAt *time.Time
}
func getVtxos(
ctx *cli.Context, explorer Explorer, client arkv1.ArkServiceClient,
addr string, computeExpiration bool,
) ([]vtxo, error) {
response, err := client.ListVtxos(ctx.Context, &arkv1.ListVtxosRequest{
Address: addr,
})
if err != nil {
return nil, err
}
vtxos := make([]vtxo, 0, len(response.GetSpendableVtxos()))
for _, v := range response.GetSpendableVtxos() {
var expireAt *time.Time
if v.ExpireAt > 0 {
t := time.Unix(v.ExpireAt, 0)
expireAt = &t
}
if v.Swept {
continue
}
vtxos = append(vtxos, vtxo{
amount: v.Receiver.Amount,
txid: v.Outpoint.Txid,
vout: v.Outpoint.Vout,
poolTxid: v.PoolTxid,
expireAt: expireAt,
})
}
if !computeExpiration {
return vtxos, nil
}
redeemBranches, err := getRedeemBranches(ctx.Context, explorer, client, vtxos)
if err != nil {
return nil, err
}
for vtxoTxid, branch := range redeemBranches {
expiration, err := branch.expireAt(ctx)
if err != nil {
return nil, err
}
for i, vtxo := range vtxos {
if vtxo.txid == vtxoTxid {
vtxos[i].expireAt = expiration
break
}
}
}
return vtxos, nil
}
func getClientFromState(ctx *cli.Context) (arkv1.ArkServiceClient, func(), error) {
state, err := getState(ctx)
if err != nil {
return nil, nil, err
}
addr := state[ASP_URL]
if len(addr) <= 0 {
return nil, nil, fmt.Errorf("missing asp url")
}
return getClient(addr)
}
func getClient(addr string) (arkv1.ArkServiceClient, func(), error) {
creds := insecure.NewCredentials()
port := 80
if strings.HasPrefix(addr, "https://") {
addr = strings.TrimPrefix(addr, "https://")
creds = credentials.NewTLS(nil)
port = 443
}
if !strings.Contains(addr, ":") {
addr = fmt.Sprintf("%s:%d", addr, port)
}
conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(creds))
if err != nil {
return nil, nil, err
}
client := arkv1.NewArkServiceClient(conn)
closeFn := func() {
err := conn.Close()
if err != nil {
fmt.Printf("error closing connection: %s\n", err)
}
}
return client, closeFn, nil
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,20 +0,0 @@
package main
import (
"github.com/urfave/cli/v2"
)
var configCommand = cli.Command{
Name: "config",
Usage: "Shows configuration of the Ark wallet",
Action: printConfigAction,
}
func printConfigAction(ctx *cli.Context) error {
state, err := getState(ctx)
if err != nil {
return err
}
return printJSON(state)
}

212
client/covenant/balance.go Normal file
View File

@@ -0,0 +1,212 @@
package covenant
import (
"fmt"
"math"
"sync"
"time"
"github.com/ark-network/ark-cli/flags"
"github.com/ark-network/ark-cli/utils"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/urfave/cli/v2"
)
func (*covenantLiquidCLI) Balance(ctx *cli.Context) error {
computeExpiryDetails := ctx.Bool(flags.ExpiryDetailsFlag.Name)
client, cancel, err := getClientFromState(ctx)
if err != nil {
return err
}
defer cancel()
offchainAddr, onchainAddr, redemptionAddr, err := getAddress(ctx)
if err != nil {
return err
}
network, err := utils.GetNetwork(ctx)
if err != nil {
return err
}
// No need to check for error here becuase this function is called also by getAddress().
// nolint:all
unilateralExitDelay, _ := utils.GetUnilateralExitDelay(ctx)
wg := &sync.WaitGroup{}
wg.Add(3)
chRes := make(chan balanceRes, 3)
go func() {
defer wg.Done()
explorer := utils.NewExplorer(ctx)
balance, amountByExpiration, err := getOffchainBalance(
ctx, explorer, client, offchainAddr, computeExpiryDetails,
)
if err != nil {
chRes <- balanceRes{0, 0, nil, nil, err}
return
}
chRes <- balanceRes{balance, 0, nil, amountByExpiration, nil}
}()
go func() {
defer wg.Done()
explorer := utils.NewExplorer(ctx)
balance, err := explorer.GetBalance(onchainAddr, toElementsNetwork(network).AssetID)
if err != nil {
chRes <- balanceRes{0, 0, nil, nil, err}
return
}
chRes <- balanceRes{0, balance, nil, nil, nil}
}()
go func() {
defer wg.Done()
explorer := utils.NewExplorer(ctx)
spendableBalance, lockedBalance, err := explorer.GetRedeemedVtxosBalance(
redemptionAddr, unilateralExitDelay,
)
if err != nil {
chRes <- balanceRes{0, 0, nil, nil, err}
return
}
chRes <- balanceRes{0, spendableBalance, lockedBalance, nil, err}
}()
wg.Wait()
lockedOnchainBalance := []map[string]interface{}{}
details := make([]map[string]interface{}, 0)
offchainBalance, onchainBalance := uint64(0), uint64(0)
nextExpiration := int64(0)
count := 0
for res := range chRes {
if res.err != nil {
return res.err
}
if res.offchainBalance > 0 {
offchainBalance = res.offchainBalance
}
if res.onchainSpendableBalance > 0 {
onchainBalance += res.onchainSpendableBalance
}
if res.offchainBalanceByExpiration != nil {
for timestamp, amount := range res.offchainBalanceByExpiration {
if nextExpiration == 0 || timestamp < nextExpiration {
nextExpiration = timestamp
}
fancyTime := time.Unix(timestamp, 0).Format("2006-01-02 15:04:05")
details = append(
details,
map[string]interface{}{
"expiry_time": fancyTime,
"amount": amount,
},
)
}
}
if res.onchainLockedBalance != nil {
for timestamp, amount := range res.onchainLockedBalance {
fancyTime := time.Unix(timestamp, 0).Format("2006-01-02 15:04:05")
lockedOnchainBalance = append(
lockedOnchainBalance,
map[string]interface{}{
"spendable_at": fancyTime,
"amount": amount,
},
)
}
}
count++
if count == 3 {
break
}
}
response := make(map[string]interface{})
response["onchain_balance"] = map[string]interface{}{
"spendable_amount": onchainBalance,
}
if len(lockedOnchainBalance) > 0 {
response["onchain_balance"].(map[string]interface{})["locked_amount"] = lockedOnchainBalance
}
offchainBalanceJSON := map[string]interface{}{
"total": offchainBalance,
}
fancyTimeExpiration := ""
if nextExpiration != 0 {
t := time.Unix(nextExpiration, 0)
if t.Before(time.Now().Add(48 * time.Hour)) {
// print the duration instead of the absolute time
until := time.Until(t)
seconds := math.Abs(until.Seconds())
minutes := math.Abs(until.Minutes())
hours := math.Abs(until.Hours())
if hours < 1 {
if minutes < 1 {
fancyTimeExpiration = fmt.Sprintf("%d seconds", int(seconds))
} else {
fancyTimeExpiration = fmt.Sprintf("%d minutes", int(minutes))
}
} else {
fancyTimeExpiration = fmt.Sprintf("%d hours", int(hours))
}
} else {
fancyTimeExpiration = t.Format("2006-01-02 15:04:05")
}
offchainBalanceJSON["next_expiration"] = fancyTimeExpiration
}
offchainBalanceJSON["details"] = details
response["offchain_balance"] = offchainBalanceJSON
return utils.PrintJSON(response)
}
type balanceRes struct {
offchainBalance uint64
onchainSpendableBalance uint64
onchainLockedBalance map[int64]uint64
offchainBalanceByExpiration map[int64]uint64
err error
}
func getOffchainBalance(
ctx *cli.Context, explorer utils.Explorer, client arkv1.ArkServiceClient,
addr string, computeExpiration bool,
) (uint64, map[int64]uint64, error) {
amountByExpiration := make(map[int64]uint64, 0)
vtxos, err := getVtxos(ctx, explorer, client, addr, computeExpiration)
if err != nil {
return 0, nil, err
}
var balance uint64
for _, vtxo := range vtxos {
balance += vtxo.amount
if vtxo.expireAt != nil {
expiration := vtxo.expireAt.Unix()
if _, ok := amountByExpiration[expiration]; !ok {
amountByExpiration[expiration] = 0
}
amountByExpiration[expiration] += vtxo.amount
}
}
return balance, amountByExpiration, nil
}

578
client/covenant/cli.go Normal file
View File

@@ -0,0 +1,578 @@
package covenant
import (
"fmt"
"math"
"time"
"github.com/ark-network/ark-cli/interfaces"
"github.com/ark-network/ark-cli/utils"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common"
"github.com/ark-network/ark/common/tree"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/urfave/cli/v2"
"github.com/vulpemventures/go-elements/address"
"github.com/vulpemventures/go-elements/elementsutil"
"github.com/vulpemventures/go-elements/network"
"github.com/vulpemventures/go-elements/payment"
"github.com/vulpemventures/go-elements/psetv2"
"github.com/vulpemventures/go-elements/taproot"
"github.com/vulpemventures/go-elements/transaction"
)
const dust = 450
type covenantLiquidCLI struct{}
func (c *covenantLiquidCLI) Receive(ctx *cli.Context) error {
offchainAddr, onchainAddr, _, err := getAddress(ctx)
if err != nil {
return err
}
return utils.PrintJSON(map[string]interface{}{
"offchain_address": offchainAddr,
"onchain_address": onchainAddr,
})
}
func (c *covenantLiquidCLI) Redeem(ctx *cli.Context) error {
addr := ctx.String("address")
amount := ctx.Uint64("amount")
force := ctx.Bool("force")
if len(addr) <= 0 && !force {
return fmt.Errorf("missing address flag (--address)")
}
if !force && amount <= 0 {
return fmt.Errorf("missing amount flag (--amount)")
}
client, clean, err := getClientFromState(ctx)
if err != nil {
return err
}
defer clean()
if force {
if amount > 0 {
fmt.Printf("WARNING: unilateral exit (--force) ignores --amount flag, it will redeem all your VTXOs\n")
}
return unilateralRedeem(ctx, client)
}
return collaborativeRedeem(ctx, client, addr, amount)
}
func New() interfaces.CLI {
return &covenantLiquidCLI{}
}
type receiver struct {
To string `json:"to"`
Amount uint64 `json:"amount"`
}
func (r *receiver) isOnchain() bool {
_, err := address.ToOutputScript(r.To)
return err == nil
}
func sendOnchain(ctx *cli.Context, receivers []receiver) (string, error) {
pset, err := psetv2.New(nil, nil, nil)
if err != nil {
return "", err
}
updater, err := psetv2.NewUpdater(pset)
if err != nil {
return "", err
}
net, err := utils.GetNetwork(ctx)
if err != nil {
return "", err
}
liquidNet := toElementsNetwork(net)
targetAmount := uint64(0)
for _, receiver := range receivers {
targetAmount += receiver.Amount
if receiver.Amount < dust {
return "", fmt.Errorf("invalid amount (%d), must be greater than dust %d", receiver.Amount, dust)
}
script, err := address.ToOutputScript(receiver.To)
if err != nil {
return "", err
}
if err := updater.AddOutputs([]psetv2.OutputArgs{
{
Asset: liquidNet.AssetID,
Amount: receiver.Amount,
Script: script,
},
}); err != nil {
return "", err
}
}
explorer := utils.NewExplorer(ctx)
utxos, delayedUtxos, change, err := coinSelectOnchain(
ctx, explorer, targetAmount, nil,
)
if err != nil {
return "", err
}
if err := addInputs(ctx, updater, utxos, delayedUtxos, &liquidNet); err != nil {
return "", err
}
if change > 0 {
_, changeAddr, _, err := getAddress(ctx)
if err != nil {
return "", err
}
changeScript, err := address.ToOutputScript(changeAddr)
if err != nil {
return "", err
}
if err := updater.AddOutputs([]psetv2.OutputArgs{
{
Asset: liquidNet.AssetID,
Amount: change,
Script: changeScript,
},
}); err != nil {
return "", err
}
}
utx, err := pset.UnsignedTx()
if err != nil {
return "", err
}
vBytes := utx.VirtualSize()
feeAmount := uint64(math.Ceil(float64(vBytes) * 0.5))
if change > feeAmount {
updater.Pset.Outputs[len(updater.Pset.Outputs)-1].Value = change - feeAmount
} else if change == feeAmount {
updater.Pset.Outputs = updater.Pset.Outputs[:len(updater.Pset.Outputs)-1]
} else { // change < feeAmount
if change > 0 {
updater.Pset.Outputs = updater.Pset.Outputs[:len(updater.Pset.Outputs)-1]
}
// reselect the difference
selected, delayedSelected, newChange, err := coinSelectOnchain(
ctx, explorer, feeAmount-change, append(utxos, delayedUtxos...),
)
if err != nil {
return "", err
}
if err := addInputs(ctx, updater, selected, delayedSelected, &liquidNet); err != nil {
return "", err
}
if newChange > 0 {
_, changeAddr, _, err := getAddress(ctx)
if err != nil {
return "", err
}
changeScript, err := address.ToOutputScript(changeAddr)
if err != nil {
return "", err
}
if err := updater.AddOutputs([]psetv2.OutputArgs{
{
Asset: liquidNet.AssetID,
Amount: newChange,
Script: changeScript,
},
}); err != nil {
return "", err
}
}
}
if err := updater.AddOutputs([]psetv2.OutputArgs{
{
Asset: liquidNet.AssetID,
Amount: feeAmount,
},
}); err != nil {
return "", err
}
prvKey, err := utils.PrivateKeyFromPassword(ctx)
if err != nil {
return "", err
}
if err := signPset(ctx, updater.Pset, explorer, prvKey); err != nil {
return "", err
}
if err := psetv2.FinalizeAll(updater.Pset); err != nil {
return "", err
}
return updater.Pset.ToBase64()
}
func coinSelectOnchain(
ctx *cli.Context,
explorer utils.Explorer, targetAmount uint64, exclude []utils.Utxo,
) ([]utils.Utxo, []utils.Utxo, uint64, error) {
_, onchainAddr, _, err := getAddress(ctx)
if err != nil {
return nil, nil, 0, err
}
fromExplorer, err := explorer.GetUtxos(onchainAddr)
if err != nil {
return nil, nil, 0, err
}
utxos := make([]utils.Utxo, 0)
selectedAmount := uint64(0)
for _, utxo := range fromExplorer {
if selectedAmount >= targetAmount {
break
}
for _, excluded := range exclude {
if utxo.Txid == excluded.Txid && utxo.Vout == excluded.Vout {
continue
}
}
utxos = append(utxos, utxo)
selectedAmount += utxo.Amount
}
if selectedAmount >= targetAmount {
return utxos, nil, selectedAmount - targetAmount, nil
}
userPubkey, err := utils.GetWalletPublicKey(ctx)
if err != nil {
return nil, nil, 0, err
}
aspPubkey, err := utils.GetAspPublicKey(ctx)
if err != nil {
return nil, nil, 0, err
}
unilateralExitDelay, err := utils.GetUnilateralExitDelay(ctx)
if err != nil {
return nil, nil, 0, err
}
vtxoTapKey, _, err := computeVtxoTaprootScript(
userPubkey, aspPubkey, uint(unilateralExitDelay),
)
if err != nil {
return nil, nil, 0, err
}
net, err := utils.GetNetwork(ctx)
if err != nil {
return nil, nil, 0, err
}
liquidNet := toElementsNetwork(net)
pay, err := payment.FromTweakedKey(vtxoTapKey, &liquidNet, nil)
if err != nil {
return nil, nil, 0, err
}
addr, err := pay.TaprootAddress()
if err != nil {
return nil, nil, 0, err
}
fromExplorer, err = explorer.GetUtxos(addr)
if err != nil {
return nil, nil, 0, err
}
delayedUtxos := make([]utils.Utxo, 0)
for _, utxo := range fromExplorer {
if selectedAmount >= targetAmount {
break
}
availableAt := time.Unix(utxo.Status.Blocktime, 0).Add(
time.Duration(unilateralExitDelay) * time.Second,
)
if availableAt.After(time.Now()) {
continue
}
for _, excluded := range exclude {
if utxo.Txid == excluded.Txid && utxo.Vout == excluded.Vout {
continue
}
}
delayedUtxos = append(delayedUtxos, utxo)
selectedAmount += utxo.Amount
}
if selectedAmount < targetAmount {
return nil, nil, 0, fmt.Errorf(
"not enough funds to cover amount %d", targetAmount,
)
}
return utxos, delayedUtxos, selectedAmount - targetAmount, nil
}
func addInputs(
ctx *cli.Context,
updater *psetv2.Updater, utxos, delayedUtxos []utils.Utxo, net *network.Network,
) error {
_, onchainAddr, _, err := getAddress(ctx)
if err != nil {
return err
}
changeScript, err := address.ToOutputScript(onchainAddr)
if err != nil {
return err
}
for _, utxo := range utxos {
if err := updater.AddInputs([]psetv2.InputArgs{
{
Txid: utxo.Txid,
TxIndex: utxo.Vout,
},
}); err != nil {
return err
}
assetID, err := elementsutil.AssetHashToBytes(utxo.Asset)
if err != nil {
return err
}
value, err := elementsutil.ValueToBytes(utxo.Amount)
if err != nil {
return err
}
witnessUtxo := transaction.TxOutput{
Asset: assetID,
Value: value,
Script: changeScript,
Nonce: []byte{0x00},
}
if err := updater.AddInWitnessUtxo(
len(updater.Pset.Inputs)-1, &witnessUtxo,
); err != nil {
return err
}
}
if len(delayedUtxos) > 0 {
userPubkey, err := utils.GetWalletPublicKey(ctx)
if err != nil {
return err
}
aspPubkey, err := utils.GetAspPublicKey(ctx)
if err != nil {
return err
}
unilateralExitDelay, err := utils.GetUnilateralExitDelay(ctx)
if err != nil {
return err
}
vtxoTapKey, leafProof, err := computeVtxoTaprootScript(
userPubkey, aspPubkey, uint(unilateralExitDelay),
)
if err != nil {
return err
}
pay, err := payment.FromTweakedKey(vtxoTapKey, net, nil)
if err != nil {
return err
}
addr, err := pay.TaprootAddress()
if err != nil {
return err
}
script, err := address.ToOutputScript(addr)
if err != nil {
return err
}
for _, utxo := range delayedUtxos {
if err := addVtxoInput(
updater,
psetv2.InputArgs{
Txid: utxo.Txid,
TxIndex: utxo.Vout,
},
uint(unilateralExitDelay),
leafProof,
); err != nil {
return err
}
assetID, err := elementsutil.AssetHashToBytes(utxo.Asset)
if err != nil {
return err
}
value, err := elementsutil.ValueToBytes(utxo.Amount)
if err != nil {
return err
}
witnessUtxo := transaction.NewTxOutput(assetID, value, script)
if err := updater.AddInWitnessUtxo(
len(updater.Pset.Inputs)-1, witnessUtxo,
); err != nil {
return err
}
}
}
return nil
}
func isOnchainOnly(receivers []*arkv1.Output) bool {
for _, receiver := range receivers {
isOnChain, _, _, err := decodeReceiverAddress(receiver.Address)
if err != nil {
continue
}
if !isOnChain {
return false
}
}
return true
}
func decodeReceiverAddress(addr string) (
bool, []byte, *secp256k1.PublicKey, error,
) {
outputScript, err := address.ToOutputScript(addr)
if err != nil {
_, userPubkey, _, err := common.DecodeAddress(addr)
if err != nil {
return false, nil, nil, err
}
return false, nil, userPubkey, nil
}
return true, outputScript, nil, nil
}
func addVtxoInput(
updater *psetv2.Updater, inputArgs psetv2.InputArgs, exitDelay uint,
tapLeafProof *taproot.TapscriptElementsProof,
) error {
sequence, err := common.BIP68EncodeAsNumber(exitDelay)
if err != nil {
return nil
}
nextInputIndex := len(updater.Pset.Inputs)
if err := updater.AddInputs([]psetv2.InputArgs{inputArgs}); err != nil {
return err
}
updater.Pset.Inputs[nextInputIndex].Sequence = sequence
return updater.AddInTapLeafScript(
nextInputIndex,
psetv2.NewTapLeafScript(
*tapLeafProof,
tree.UnspendableKey(),
),
)
}
func getAddress(ctx *cli.Context) (offchainAddr, onchainAddr, redemptionAddr string, err error) {
userPubkey, err := utils.GetWalletPublicKey(ctx)
if err != nil {
return
}
aspPubkey, err := utils.GetAspPublicKey(ctx)
if err != nil {
return
}
unilateralExitDelay, err := utils.GetUnilateralExitDelay(ctx)
if err != nil {
return
}
arkNet, err := utils.GetNetwork(ctx)
if err != nil {
return
}
arkAddr, err := common.EncodeAddress(arkNet.Addr, userPubkey, aspPubkey)
if err != nil {
return
}
liquidNet := toElementsNetwork(arkNet)
p2wpkh := payment.FromPublicKey(userPubkey, &liquidNet, nil)
liquidAddr, err := p2wpkh.WitnessPubKeyHash()
if err != nil {
return
}
vtxoTapKey, _, err := computeVtxoTaprootScript(
userPubkey, aspPubkey, uint(unilateralExitDelay),
)
if err != nil {
return
}
payment, err := payment.FromTweakedKey(vtxoTapKey, &liquidNet, nil)
if err != nil {
return
}
redemptionAddr, err = payment.TaprootAddress()
if err != nil {
return
}
offchainAddr = arkAddr
onchainAddr = liquidAddr
return
}

491
client/covenant/client.go Normal file
View File

@@ -0,0 +1,491 @@
package covenant
import (
"bytes"
"context"
"fmt"
"io"
"strings"
"time"
"github.com/ark-network/ark-cli/utils"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common"
"github.com/ark-network/ark/common/tree"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/urfave/cli/v2"
"github.com/vulpemventures/go-elements/psetv2"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)
type vtxo struct {
amount uint64
txid string
vout uint32
poolTxid string
expireAt *time.Time
}
func getVtxos(
ctx *cli.Context, explorer utils.Explorer, client arkv1.ArkServiceClient,
addr string, computeExpiration bool,
) ([]vtxo, error) {
response, err := client.ListVtxos(ctx.Context, &arkv1.ListVtxosRequest{
Address: addr,
})
if err != nil {
return nil, err
}
vtxos := make([]vtxo, 0, len(response.GetSpendableVtxos()))
for _, v := range response.GetSpendableVtxos() {
var expireAt *time.Time
if v.ExpireAt > 0 {
t := time.Unix(v.ExpireAt, 0)
expireAt = &t
}
if v.Swept {
continue
}
vtxos = append(vtxos, vtxo{
amount: v.Receiver.Amount,
txid: v.Outpoint.Txid,
vout: v.Outpoint.Vout,
poolTxid: v.PoolTxid,
expireAt: expireAt,
})
}
if !computeExpiration {
return vtxos, nil
}
redeemBranches, err := getRedeemBranches(ctx.Context, explorer, client, vtxos)
if err != nil {
return nil, err
}
for vtxoTxid, branch := range redeemBranches {
expiration, err := branch.expireAt(ctx)
if err != nil {
return nil, err
}
for i, vtxo := range vtxos {
if vtxo.txid == vtxoTxid {
vtxos[i].expireAt = expiration
break
}
}
}
return vtxos, nil
}
func getClientFromState(ctx *cli.Context) (arkv1.ArkServiceClient, func(), error) {
state, err := utils.GetState(ctx)
if err != nil {
return nil, nil, err
}
addr := state[utils.ASP_URL]
if len(addr) <= 0 {
return nil, nil, fmt.Errorf("missing asp url")
}
return getClient(addr)
}
func getClient(addr string) (arkv1.ArkServiceClient, func(), error) {
creds := insecure.NewCredentials()
port := 80
if strings.HasPrefix(addr, "https://") {
addr = strings.TrimPrefix(addr, "https://")
creds = credentials.NewTLS(nil)
port = 443
}
if !strings.Contains(addr, ":") {
addr = fmt.Sprintf("%s:%d", addr, port)
}
conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(creds))
if err != nil {
return nil, nil, err
}
client := arkv1.NewArkServiceClient(conn)
closeFn := func() {
err := conn.Close()
if err != nil {
fmt.Printf("error closing connection: %s\n", err)
}
}
return client, closeFn, nil
}
func getRedeemBranches(
ctx context.Context, explorer utils.Explorer, client arkv1.ArkServiceClient,
vtxos []vtxo,
) (map[string]*redeemBranch, error) {
congestionTrees := make(map[string]tree.CongestionTree, 0)
redeemBranches := make(map[string]*redeemBranch, 0)
for _, vtxo := range vtxos {
if _, ok := congestionTrees[vtxo.poolTxid]; !ok {
round, err := client.GetRound(ctx, &arkv1.GetRoundRequest{
Txid: vtxo.poolTxid,
})
if err != nil {
return nil, err
}
treeFromRound := round.GetRound().GetCongestionTree()
congestionTree, err := toCongestionTree(treeFromRound)
if err != nil {
return nil, err
}
congestionTrees[vtxo.poolTxid] = congestionTree
}
redeemBranch, err := newRedeemBranch(
explorer, congestionTrees[vtxo.poolTxid], vtxo,
)
if err != nil {
return nil, err
}
redeemBranches[vtxo.txid] = redeemBranch
}
return redeemBranches, nil
}
func toCongestionTree(treeFromProto *arkv1.Tree) (tree.CongestionTree, error) {
levels := make(tree.CongestionTree, 0, len(treeFromProto.Levels))
for _, level := range treeFromProto.Levels {
nodes := make([]tree.Node, 0, len(level.Nodes))
for _, node := range level.Nodes {
nodes = append(nodes, tree.Node{
Txid: node.Txid,
Tx: node.Tx,
ParentTxid: node.ParentTxid,
Leaf: false,
})
}
levels = append(levels, nodes)
}
for j, treeLvl := range levels {
for i, node := range treeLvl {
if len(levels.Children(node.Txid)) == 0 {
levels[j][i].Leaf = true
}
}
}
return levels, nil
}
// castCongestionTree converts a tree.CongestionTree to a repeated arkv1.TreeLevel
func castCongestionTree(congestionTree tree.CongestionTree) *arkv1.Tree {
levels := make([]*arkv1.TreeLevel, 0, len(congestionTree))
for _, level := range congestionTree {
levelProto := &arkv1.TreeLevel{
Nodes: make([]*arkv1.Node, 0, len(level)),
}
for _, node := range level {
levelProto.Nodes = append(levelProto.Nodes, &arkv1.Node{
Txid: node.Txid,
Tx: node.Tx,
ParentTxid: node.ParentTxid,
})
}
levels = append(levels, levelProto)
}
return &arkv1.Tree{
Levels: levels,
}
}
func handleRoundStream(
ctx *cli.Context, client arkv1.ArkServiceClient, paymentID string,
vtxosToSign []vtxo, secKey *secp256k1.PrivateKey, receivers []*arkv1.Output,
) (poolTxID string, err error) {
stream, err := client.GetEventStream(ctx.Context, &arkv1.GetEventStreamRequest{})
if err != nil {
return "", err
}
var pingStop func()
pingReq := &arkv1.PingRequest{
PaymentId: paymentID,
}
for pingStop == nil {
pingStop = ping(ctx.Context, client, pingReq)
}
defer pingStop()
for {
event, err := stream.Recv()
if err == io.EOF {
break
}
if err != nil {
return "", err
}
if e := event.GetRoundFailed(); e != nil {
pingStop()
return "", fmt.Errorf("round failed: %s", e.GetReason())
}
if e := event.GetRoundFinalization(); e != nil {
// stop pinging as soon as we receive some forfeit txs
pingStop()
fmt.Println("round finalization started")
poolTx := e.GetPoolTx()
ptx, err := psetv2.NewPsetFromBase64(poolTx)
if err != nil {
return "", err
}
congestionTree, err := toCongestionTree(e.GetCongestionTree())
if err != nil {
return "", err
}
connectors := e.GetConnectors()
aspPubkey, err := utils.GetAspPublicKey(ctx)
if err != nil {
return "", err
}
roundLifetime, err := utils.GetRoundLifetime(ctx)
if err != nil {
return "", err
}
if !isOnchainOnly(receivers) {
// validate the congestion tree
if err := tree.ValidateCongestionTree(
congestionTree, poolTx, aspPubkey, int64(roundLifetime),
); err != nil {
return "", err
}
}
if err := common.ValidateConnectors(poolTx, connectors); err != nil {
return "", err
}
unilateralExitDelay, err := utils.GetUnilateralExitDelay(ctx)
if err != nil {
return "", err
}
for _, receiver := range receivers {
isOnChain, onchainScript, userPubkey, err := decodeReceiverAddress(
receiver.Address,
)
if err != nil {
return "", err
}
if isOnChain {
// collaborative exit case
// search for the output in the pool tx
found := false
for _, output := range ptx.Outputs {
if bytes.Equal(output.Script, onchainScript) {
if output.Value != receiver.Amount {
return "", fmt.Errorf(
"invalid collaborative exit output amount: got %d, want %d",
output.Value, receiver.Amount,
)
}
found = true
break
}
}
if !found {
return "", fmt.Errorf(
"collaborative exit output not found: %s", receiver.Address,
)
}
continue
}
// off-chain send case
// search for the output in congestion tree
found := false
// compute the receiver output taproot key
outputTapKey, _, err := computeVtxoTaprootScript(
userPubkey, aspPubkey, uint(unilateralExitDelay),
)
if err != nil {
return "", err
}
leaves := congestionTree.Leaves()
for _, leaf := range leaves {
tx, err := psetv2.NewPsetFromBase64(leaf.Tx)
if err != nil {
return "", err
}
for _, output := range tx.Outputs {
if len(output.Script) == 0 {
continue
}
if bytes.Equal(
output.Script[2:], schnorr.SerializePubKey(outputTapKey),
) {
if output.Value != receiver.Amount {
continue
}
found = true
break
}
}
if found {
break
}
}
if !found {
return "", fmt.Errorf(
"off-chain send output not found: %s", receiver.Address,
)
}
}
fmt.Println("congestion tree validated")
forfeits := e.GetForfeitTxs()
signedForfeits := make([]string, 0)
fmt.Print("signing forfeit txs... ")
explorer := utils.NewExplorer(ctx)
connectorsTxids := make([]string, 0, len(connectors))
for _, connector := range connectors {
p, _ := psetv2.NewPsetFromBase64(connector)
utx, _ := p.UnsignedTx()
txid := utx.TxHash().String()
connectorsTxids = append(connectorsTxids, txid)
}
for _, forfeit := range forfeits {
pset, err := psetv2.NewPsetFromBase64(forfeit)
if err != nil {
return "", err
}
for _, input := range pset.Inputs {
inputTxid := chainhash.Hash(input.PreviousTxid).String()
for _, coin := range vtxosToSign {
// check if it contains one of the input to sign
if inputTxid == coin.txid {
// verify that the connector is in the connectors list
connectorTxid := chainhash.Hash(pset.Inputs[0].PreviousTxid).String()
connectorFound := false
for _, txid := range connectorsTxids {
if txid == connectorTxid {
connectorFound = true
break
}
}
if !connectorFound {
return "", fmt.Errorf("connector txid %s not found in the connectors list", connectorTxid)
}
if err := signPset(ctx, pset, explorer, secKey); err != nil {
return "", err
}
signedPset, err := pset.ToBase64()
if err != nil {
return "", err
}
signedForfeits = append(signedForfeits, signedPset)
}
}
}
}
// if no forfeit txs have been signed, start pinging again and wait for the next round
if len(signedForfeits) == 0 {
fmt.Printf("\nno forfeit txs to sign, waiting for the next round...\n")
pingStop = nil
for pingStop == nil {
pingStop = ping(ctx.Context, client, pingReq)
}
continue
}
fmt.Printf("%d signed\n", len(signedForfeits))
fmt.Print("finalizing payment... ")
_, err = client.FinalizePayment(ctx.Context, &arkv1.FinalizePaymentRequest{
SignedForfeitTxs: signedForfeits,
})
if err != nil {
return "", err
}
fmt.Print("done.\n")
fmt.Println("waiting for round finalization...")
continue
}
if event.GetRoundFinalized() != nil {
return event.GetRoundFinalized().GetPoolTxid(), nil
}
}
return "", fmt.Errorf("stream closed unexpectedly")
}
// send 1 ping message every 5 seconds to signal to the ark service that we are still alive
// returns a function that can be used to stop the pinging
func ping(
ctx context.Context, client arkv1.ArkServiceClient, req *arkv1.PingRequest,
) func() {
_, err := client.Ping(ctx, req)
if err != nil {
return nil
}
ticker := time.NewTicker(5 * time.Second)
go func(t *time.Ticker) {
for range t.C {
// nolint
client.Ping(ctx, req)
}
}(ticker)
return ticker.Stop
}

View File

@@ -1,4 +1,4 @@
package main
package covenant
import (
"encoding/hex"
@@ -8,6 +8,7 @@ import (
"strconv"
"strings"
"github.com/ark-network/ark-cli/utils"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common"
"github.com/btcsuite/btcd/btcec/v2"
@@ -16,35 +17,13 @@ import (
"github.com/vulpemventures/go-elements/network"
)
var (
privateKeyFlag = cli.StringFlag{
Name: "prvkey",
Usage: "optional, private key to encrypt",
}
networkFlag = cli.StringFlag{
Name: "network",
Usage: "network to use (liquid, testnet, regtest)",
Value: "liquid",
}
urlFlag = cli.StringFlag{
Name: "ark-url",
Usage: "the url of the ASP to connect to",
Required: true,
}
explorerFlag = cli.StringFlag{
Name: "explorer",
Usage: "the url of the explorer to use",
}
)
var initCommand = cli.Command{
Name: "init",
Usage: "Initialize your Ark wallet with an encryption password, and connect it to an ASP",
Action: initAction,
Flags: []cli.Flag{&passwordFlag, &privateKeyFlag, &networkFlag, &urlFlag, &explorerFlag},
var explorerUrls = map[string]string{
common.Liquid.Name: "https://blockstream.info/liquid/api",
common.LiquidTestNet.Name: "https://blockstream.info/liquidtestnet/api",
common.LiquidRegTest.Name: "http://localhost:3001",
}
func initAction(ctx *cli.Context) error {
func (c *covenantLiquidCLI) Init(ctx *cli.Context) error {
key := ctx.String("prvkey")
net := strings.ToLower(ctx.String("network"))
url := ctx.String("ark-url")
@@ -55,26 +34,24 @@ func initAction(ctx *cli.Context) error {
if len(url) <= 0 {
return fmt.Errorf("invalid ark url")
}
if net != common.Liquid.Name && net != common.LiquidTestNet.Name &&
net != common.LiquidRegTest.Name {
if net != common.Liquid.Name && net != common.LiquidTestNet.Name && net != common.LiquidRegTest.Name {
return fmt.Errorf("invalid network")
}
if len(explorer) > 0 {
explorerURL = explorer
_, network := networkFromString(net)
if err := testEsploraEndpoint(network, explorerURL); err != nil {
if err := testEsploraEndpoint(toElementsNetworkFromName(net), explorerURL); err != nil {
return fmt.Errorf("failed to connect with explorer: %s", err)
}
} else {
explorerURL = explorerUrl[net]
explorerURL = explorerUrls[net]
}
if err := connectToAsp(ctx, net, url, explorerURL); err != nil {
return err
}
password, err := readPassword(ctx, false)
password, err := utils.ReadPassword(ctx, false)
if err != nil {
return err
}
@@ -90,6 +67,24 @@ func generateRandomPrivateKey() (*secp256k1.PrivateKey, error) {
return privKey, nil
}
func testEsploraEndpoint(net network.Network, url string) error {
endpoint := fmt.Sprintf("%s/asset/%s", url, net.AssetID)
resp, err := http.Get(endpoint)
if err != nil {
return fmt.Errorf("failed to connect with explorer: (%s) %s", endpoint, err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
if resp.StatusCode != http.StatusOK {
return fmt.Errorf(endpoint + " " + string(body))
}
return nil
}
func connectToAsp(ctx *cli.Context, net, url, explorer string) error {
client, close, err := getClient(url)
if err != nil {
@@ -102,13 +97,13 @@ func connectToAsp(ctx *cli.Context, net, url, explorer string) error {
return err
}
return setState(ctx, map[string]string{
ASP_URL: url,
NETWORK: net,
ASP_PUBKEY: resp.Pubkey,
ROUND_LIFETIME: strconv.Itoa(int(resp.GetRoundLifetime())),
UNILATERAL_EXIT_DELAY: strconv.Itoa(int(resp.GetUnilateralExitDelay())),
EXPLORER: explorer,
return utils.SetState(ctx, map[string]string{
utils.ASP_URL: url,
utils.NETWORK: net,
utils.ASP_PUBKEY: resp.Pubkey,
utils.ROUND_LIFETIME: strconv.Itoa(int(resp.GetRoundLifetime())),
utils.UNILATERAL_EXIT_DELAY: strconv.Itoa(int(resp.GetUnilateralExitDelay())),
utils.EXPLORER: explorer,
})
}
@@ -129,43 +124,26 @@ func initWallet(ctx *cli.Context, key string, password []byte) error {
privateKey = secp256k1.PrivKeyFromBytes(privKeyBytes)
}
cypher := newAES128Cypher()
cypher := utils.NewAES128Cypher()
buf := privateKey.Serialize()
encryptedPrivateKey, err := cypher.encrypt(buf, password)
encryptedPrivateKey, err := cypher.Encrypt(buf, password)
if err != nil {
return err
}
passwordHash := hashPassword([]byte(password))
passwordHash := utils.HashPassword([]byte(password))
pubkey := privateKey.PubKey().SerializeCompressed()
state := map[string]string{
ENCRYPTED_PRVKEY: hex.EncodeToString(encryptedPrivateKey),
PASSWORD_HASH: hex.EncodeToString(passwordHash),
PUBKEY: hex.EncodeToString(pubkey),
utils.ENCRYPTED_PRVKEY: hex.EncodeToString(encryptedPrivateKey),
utils.PASSWORD_HASH: hex.EncodeToString(passwordHash),
utils.PUBKEY: hex.EncodeToString(pubkey),
}
if err := setState(ctx, state); err != nil {
if err := utils.SetState(ctx, state); err != nil {
return err
}
fmt.Println("wallet initialized")
return nil
}
func testEsploraEndpoint(net *network.Network, url string) error {
resp, err := http.Get(fmt.Sprintf("%s/asset/%s", url, net.AssetID))
if err != nil {
return err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
if resp.StatusCode != http.StatusOK {
return fmt.Errorf(string(body))
}
return nil
}

View File

@@ -0,0 +1,26 @@
package covenant
import (
"fmt"
"github.com/ark-network/ark/common"
"github.com/vulpemventures/go-elements/network"
)
func toElementsNetworkFromName(name string) network.Network {
switch name {
case common.Liquid.Name:
return network.Liquid
case common.LiquidTestNet.Name:
return network.Testnet
case common.LiquidRegTest.Name:
return network.Regtest
default:
fmt.Printf("unknown network")
return network.Liquid
}
}
func toElementsNetwork(net *common.Network) network.Network {
return toElementsNetworkFromName(net.Name)
}

View File

@@ -1,9 +1,10 @@
package main
package covenant
import (
"encoding/hex"
"fmt"
"github.com/ark-network/ark-cli/utils"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common/tree"
"github.com/urfave/cli/v2"
@@ -11,29 +12,9 @@ import (
"github.com/vulpemventures/go-elements/psetv2"
)
const (
minRelayFee = 30
)
const minRelayFee = 30
var (
amountOnboardFlag = cli.Uint64Flag{
Name: "amount",
Usage: "amount to onboard in sats",
}
trustedOnboardFlag = cli.BoolFlag{
Name: "trusted",
Usage: "trusted onboard",
}
)
var onboardCommand = cli.Command{
Name: "onboard",
Usage: "Onboard the Ark by lifting your funds",
Action: onboardAction,
Flags: []cli.Flag{&amountOnboardFlag, &trustedOnboardFlag, &passwordFlag},
}
func onboardAction(ctx *cli.Context) error {
func (c *covenantLiquidCLI) Onboard(ctx *cli.Context) error {
isTrusted := ctx.Bool("trusted")
amount := ctx.Uint64("amount")
@@ -42,9 +23,12 @@ func onboardAction(ctx *cli.Context) error {
return fmt.Errorf("missing amount flag (--amount)")
}
_, net := getNetwork(ctx)
net, err := utils.GetNetwork(ctx)
if err != nil {
return err
}
userPubKey, err := getWalletPublicKey(ctx)
userPubKey, err := utils.GetWalletPublicKey(ctx)
if err != nil {
return err
}
@@ -63,22 +47,22 @@ func onboardAction(ctx *cli.Context) error {
return err
}
return printJSON(map[string]interface{}{
return utils.PrintJSON(map[string]interface{}{
"onboard_address": resp.Address,
})
}
aspPubkey, err := getAspPublicKey(ctx)
aspPubkey, err := utils.GetAspPublicKey(ctx)
if err != nil {
return err
}
roundLifetime, err := getRoundLifetime(ctx)
roundLifetime, err := utils.GetRoundLifetime(ctx)
if err != nil {
return err
}
unilateralExitDelay, err := getUnilateralExitDelay(ctx)
unilateralExitDelay, err := utils.GetUnilateralExitDelay(ctx)
if err != nil {
return err
}
@@ -88,15 +72,17 @@ func onboardAction(ctx *cli.Context) error {
Amount: amount,
}
liquidNet := toElementsNetwork(net)
treeFactoryFn, sharedOutputScript, sharedOutputAmount, err := tree.CraftCongestionTree(
net.AssetID, aspPubkey, []tree.Receiver{congestionTreeLeaf},
liquidNet.AssetID, aspPubkey, []tree.Receiver{congestionTreeLeaf},
minRelayFee, roundLifetime, unilateralExitDelay,
)
if err != nil {
return err
}
pay, err := payment.FromScript(sharedOutputScript, net, nil)
pay, err := payment.FromScript(sharedOutputScript, &liquidNet, nil)
if err != nil {
return err
}

View File

@@ -1,4 +1,4 @@
package main
package covenant
import (
"bufio"
@@ -8,71 +8,12 @@ import (
"strings"
"time"
"github.com/ark-network/ark-cli/utils"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/urfave/cli/v2"
"github.com/vulpemventures/go-elements/address"
)
var (
addressFlag = cli.StringFlag{
Name: "address",
Usage: "main chain address receiving the redeeemed VTXO",
Value: "",
Required: false,
}
amountToRedeemFlag = cli.Uint64Flag{
Name: "amount",
Usage: "amount to redeem",
Value: 0,
Required: false,
}
forceFlag = cli.BoolFlag{
Name: "force",
Usage: "force redemption without collaborate with the Ark service provider",
Value: false,
Required: false,
}
)
var redeemCommand = cli.Command{
Name: "redeem",
Usage: "Redeem your offchain funds, either collaboratively or unilaterally",
Flags: []cli.Flag{&addressFlag, &amountToRedeemFlag, &forceFlag, &passwordFlag, &enableExpiryCoinselectFlag},
Action: redeemAction,
}
func redeemAction(ctx *cli.Context) error {
addr := ctx.String("address")
amount := ctx.Uint64("amount")
force := ctx.Bool("force")
if len(addr) <= 0 && !force {
return fmt.Errorf("missing address flag (--address)")
}
if !force && amount <= 0 {
return fmt.Errorf("missing amount flag (--amount)")
}
client, clean, err := getClientFromState(ctx)
if err != nil {
return err
}
defer clean()
if force {
if amount > 0 {
fmt.Printf("WARNING: unilateral exit (--force) ignores --amount flag, it will redeem all your VTXOs\n")
}
return unilateralRedeem(ctx, client)
}
return collaborativeRedeem(ctx, client, addr, amount)
}
func collaborativeRedeem(
ctx *cli.Context, client arkv1.ArkServiceClient, addr string, amount uint64,
) error {
@@ -86,7 +27,13 @@ func collaborativeRedeem(
if err != nil {
return fmt.Errorf("invalid onchain address: unknown network")
}
_, liquidNet := getNetwork(ctx)
netinstate, err := utils.GetNetwork(ctx)
if err != nil {
return err
}
liquidNet := toElementsNetwork(netinstate)
if net.Name != liquidNet.Name {
return fmt.Errorf("invalid onchain address: must be for %s network", liquidNet.Name)
}
@@ -108,7 +55,7 @@ func collaborativeRedeem(
},
}
explorer := NewExplorer(ctx)
explorer := utils.NewExplorer(ctx)
vtxos, err := getVtxos(ctx, explorer, client, offchainAddr, withExpiryCoinselect)
if err != nil {
@@ -136,7 +83,7 @@ func collaborativeRedeem(
})
}
secKey, err := privateKeyFromPassword(ctx)
secKey, err := utils.PrivateKeyFromPassword(ctx)
if err != nil {
return err
}
@@ -168,13 +115,9 @@ func collaborativeRedeem(
return err
}
if err := printJSON(map[string]interface{}{
return utils.PrintJSON(map[string]interface{}{
"pool_txid": poolTxID,
}); err != nil {
return err
}
return nil
})
}
func unilateralRedeem(ctx *cli.Context, client arkv1.ArkServiceClient) error {
@@ -183,7 +126,7 @@ func unilateralRedeem(ctx *cli.Context, client arkv1.ArkServiceClient) error {
return err
}
explorer := NewExplorer(ctx)
explorer := utils.NewExplorer(ctx)
vtxos, err := getVtxos(ctx, explorer, client, offchainAddr, false)
if err != nil {
return err

View File

@@ -1,9 +1,10 @@
package main
package covenant
import (
"fmt"
"time"
"github.com/ark-network/ark-cli/utils"
"github.com/ark-network/ark/common/tree"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
@@ -18,11 +19,11 @@ type redeemBranch struct {
internalKey *secp256k1.PublicKey
sweepClosure *taproot.TapElementsLeaf
lifetime time.Duration
explorer Explorer
explorer utils.Explorer
}
func newRedeemBranch(
explorer Explorer,
explorer utils.Explorer,
congestionTree tree.CongestionTree, vtxo vtxo,
) (*redeemBranch, error) {
sweepClosure, seconds, err := findSweepClosure(congestionTree)
@@ -116,10 +117,10 @@ func (r *redeemBranch) redeemPath() ([]string, error) {
return transactions, nil
}
func (r *redeemBranch) expireAt(ctx *cli.Context) (*time.Time, error) {
func (r *redeemBranch) expireAt(*cli.Context) (*time.Time, error) {
lastKnownBlocktime := int64(0)
confirmed, blocktime, _ := getTxBlocktime(ctx, r.vtxo.poolTxid)
confirmed, blocktime, _ := r.explorer.GetTxBlocktime(r.vtxo.poolTxid)
if confirmed {
lastKnownBlocktime = blocktime
@@ -132,7 +133,7 @@ func (r *redeemBranch) expireAt(ctx *cli.Context) (*time.Time, error) {
utx, _ := pset.UnsignedTx()
txid := utx.TxHash().String()
confirmed, blocktime, err := getTxBlocktime(ctx, txid)
confirmed, blocktime, err := r.explorer.GetTxBlocktime(txid)
if err != nil {
break
}
@@ -157,7 +158,6 @@ func (r *redeemBranch) offchainPath() ([]*psetv2.Pset, error) {
pset := r.branch[i]
unsignedTx, err := pset.UnsignedTx()
if err != nil {
fmt.Println("error", err)
return nil, err
}
@@ -180,3 +180,39 @@ func (r *redeemBranch) offchainPath() ([]*psetv2.Pset, error) {
return offchainPath, nil
}
func findSweepClosure(
congestionTree tree.CongestionTree,
) (*taproot.TapElementsLeaf, uint, error) {
root, err := congestionTree.Root()
if err != nil {
return nil, 0, err
}
// find the sweep closure
tx, err := psetv2.NewPsetFromBase64(root.Tx)
if err != nil {
return nil, 0, err
}
var seconds uint
var sweepClosure *taproot.TapElementsLeaf
for _, tapLeaf := range tx.Inputs[0].TapLeafScript {
closure := &tree.CSVSigClosure{}
valid, err := closure.Decode(tapLeaf.Script)
if err != nil {
continue
}
if valid && closure.Seconds > seconds {
seconds = closure.Seconds
sweepClosure = &tapLeaf.TapElementsLeaf
}
}
if sweepClosure == nil {
return nil, 0, fmt.Errorf("sweep closure not found")
}
return sweepClosure, seconds, nil
}

224
client/covenant/send.go Normal file
View File

@@ -0,0 +1,224 @@
package covenant
import (
"bytes"
"encoding/json"
"fmt"
"sort"
"github.com/ark-network/ark-cli/utils"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common"
"github.com/urfave/cli/v2"
)
func (c *covenantLiquidCLI) Send(ctx *cli.Context) error {
if !ctx.IsSet("receivers") && !ctx.IsSet("to") && !ctx.IsSet("amount") {
return fmt.Errorf("missing destination, either use --to and --amount to send or --receivers to send to many")
}
receivers := ctx.String("receivers")
to := ctx.String("to")
amount := ctx.Uint64("amount")
var receiversJSON []receiver
if len(receivers) > 0 {
if err := json.Unmarshal([]byte(receivers), &receiversJSON); err != nil {
return fmt.Errorf("invalid receivers: %s", err)
}
} else {
receiversJSON = []receiver{
{
To: to,
Amount: amount,
},
}
}
if len(receiversJSON) <= 0 {
return fmt.Errorf("no receivers specified")
}
onchainReceivers := make([]receiver, 0)
offchainReceivers := make([]receiver, 0)
for _, receiver := range receiversJSON {
if receiver.isOnchain() {
onchainReceivers = append(onchainReceivers, receiver)
} else {
offchainReceivers = append(offchainReceivers, receiver)
}
}
explorer := utils.NewExplorer(ctx)
if len(onchainReceivers) > 0 {
pset, err := sendOnchain(ctx, onchainReceivers)
if err != nil {
return err
}
txid, err := explorer.Broadcast(pset)
if err != nil {
return err
}
return utils.PrintJSON(map[string]interface{}{
"txid": txid,
})
}
if len(offchainReceivers) > 0 {
if err := sendOffchain(ctx, offchainReceivers); err != nil {
return err
}
}
return nil
}
func sendOffchain(ctx *cli.Context, receivers []receiver) error {
withExpiryCoinselect := ctx.Bool("enable-expiry-coinselect")
offchainAddr, _, _, err := getAddress(ctx)
if err != nil {
return err
}
_, _, aspPubKey, err := common.DecodeAddress(offchainAddr)
if err != nil {
return err
}
receiversOutput := make([]*arkv1.Output, 0)
sumOfReceivers := uint64(0)
for _, receiver := range receivers {
_, _, aspKey, err := common.DecodeAddress(receiver.To)
if err != nil {
return fmt.Errorf("invalid receiver address: %s", err)
}
if !bytes.Equal(
aspPubKey.SerializeCompressed(), aspKey.SerializeCompressed(),
) {
return fmt.Errorf("invalid receiver address '%s': must be associated with the connected service provider", receiver.To)
}
if receiver.Amount < dust {
return fmt.Errorf("invalid amount (%d), must be greater than dust %d", receiver.Amount, dust)
}
receiversOutput = append(receiversOutput, &arkv1.Output{
Address: receiver.To,
Amount: uint64(receiver.Amount),
})
sumOfReceivers += receiver.Amount
}
client, close, err := getClientFromState(ctx)
if err != nil {
return err
}
defer close()
explorer := utils.NewExplorer(ctx)
vtxos, err := getVtxos(ctx, explorer, client, offchainAddr, withExpiryCoinselect)
if err != nil {
return err
}
selectedCoins, changeAmount, err := coinSelect(vtxos, sumOfReceivers, withExpiryCoinselect)
if err != nil {
return err
}
if changeAmount > 0 {
changeReceiver := &arkv1.Output{
Address: offchainAddr,
Amount: changeAmount,
}
receiversOutput = append(receiversOutput, changeReceiver)
}
inputs := make([]*arkv1.Input, 0, len(selectedCoins))
for _, coin := range selectedCoins {
inputs = append(inputs, &arkv1.Input{
Txid: coin.txid,
Vout: coin.vout,
})
}
secKey, err := utils.PrivateKeyFromPassword(ctx)
if err != nil {
return err
}
registerResponse, err := client.RegisterPayment(
ctx.Context, &arkv1.RegisterPaymentRequest{Inputs: inputs},
)
if err != nil {
return err
}
_, err = client.ClaimPayment(ctx.Context, &arkv1.ClaimPaymentRequest{
Id: registerResponse.GetId(),
Outputs: receiversOutput,
})
if err != nil {
return err
}
poolTxID, err := handleRoundStream(
ctx, client, registerResponse.GetId(),
selectedCoins, secKey, receiversOutput,
)
if err != nil {
return err
}
return utils.PrintJSON(map[string]interface{}{
"pool_txid": poolTxID,
})
}
func coinSelect(vtxos []vtxo, amount uint64, sortByExpirationTime bool) ([]vtxo, uint64, error) {
selected := make([]vtxo, 0)
notSelected := make([]vtxo, 0)
selectedAmount := uint64(0)
if sortByExpirationTime {
// sort vtxos by expiration (older first)
sort.SliceStable(vtxos, func(i, j int) bool {
if vtxos[i].expireAt == nil || vtxos[j].expireAt == nil {
return false
}
return vtxos[i].expireAt.Before(*vtxos[j].expireAt)
})
}
for _, vtxo := range vtxos {
if selectedAmount >= amount {
notSelected = append(notSelected, vtxo)
break
}
selected = append(selected, vtxo)
selectedAmount += vtxo.amount
}
if selectedAmount < amount {
return nil, 0, fmt.Errorf("not enough funds to cover amount%d", amount)
}
change := selectedAmount - amount
if change < dust {
if len(notSelected) > 0 {
selected = append(selected, notSelected[0])
change += notSelected[0].amount
}
}
return selected, change, nil
}

View File

@@ -1,9 +1,10 @@
package main
package covenant
import (
"bytes"
"fmt"
"github.com/ark-network/ark-cli/utils"
"github.com/ark-network/ark/common/tree"
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
@@ -18,7 +19,7 @@ import (
)
func signPset(
ctx *cli.Context, pset *psetv2.Pset, explorer Explorer, prvKey *secp256k1.PrivateKey,
ctx *cli.Context, pset *psetv2.Pset, explorer utils.Explorer, prvKey *secp256k1.PrivateKey,
) error {
updater, err := psetv2.NewUpdater(pset)
if err != nil {
@@ -80,7 +81,10 @@ func signPset(
return err
}
_, liquidNet := getNetwork(ctx)
net, err := utils.GetNetwork(ctx)
if err != nil {
return err
}
prevoutsScripts := make([][]byte, 0)
prevoutsValues := make([][]byte, 0)
@@ -92,9 +96,11 @@ func signPset(
prevoutsAssets = append(prevoutsAssets, input.WitnessUtxo.Asset)
}
liquidNet := toElementsNetwork(net)
for i, input := range pset.Inputs {
if bytes.Equal(input.WitnessUtxo.Script, onchainWalletScript) {
p, err := payment.FromScript(input.WitnessUtxo.Script, liquidNet, nil)
p, err := payment.FromScript(input.WitnessUtxo.Script, &liquidNet, nil)
if err != nil {
return err
}

45
client/covenant/vtxo.go Normal file
View File

@@ -0,0 +1,45 @@
package covenant
import (
"github.com/ark-network/ark/common/tree"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/vulpemventures/go-elements/taproot"
)
func computeVtxoTaprootScript(
userPubkey, aspPubkey *secp256k1.PublicKey, exitDelay uint,
) (*secp256k1.PublicKey, *taproot.TapscriptElementsProof, error) {
redeemClosure := &tree.CSVSigClosure{
Pubkey: userPubkey,
Seconds: exitDelay,
}
forfeitClosure := &tree.ForfeitClosure{
Pubkey: userPubkey,
AspPubkey: aspPubkey,
}
redeemLeaf, err := redeemClosure.Leaf()
if err != nil {
return nil, nil, err
}
forfeitLeaf, err := forfeitClosure.Leaf()
if err != nil {
return nil, nil, err
}
vtxoTaprootTree := taproot.AssembleTaprootScriptTree(
*redeemLeaf, *forfeitLeaf,
)
root := vtxoTaprootTree.RootNode.TapHash()
unspendableKey := tree.UnspendableKey()
vtxoTaprootKey := taproot.ComputeTaprootOutputKey(unspendableKey, root[:])
redeemLeafHash := redeemLeaf.TapHash()
proofIndex := vtxoTaprootTree.LeafProofIndex[redeemLeafHash]
proof := vtxoTaprootTree.LeafMerkleProofs[proofIndex]
return vtxoTaprootKey, &proof, nil
}

View File

@@ -1,4 +1,4 @@
package main
package covenantless
import (
"fmt"
@@ -6,25 +6,14 @@ import (
"sync"
"time"
"github.com/ark-network/ark-cli/flags"
"github.com/ark-network/ark-cli/utils"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/urfave/cli/v2"
)
var expiryDetailsFlag = cli.BoolFlag{
Name: "compute-expiry-details",
Usage: "compute client-side the VTXOs expiry time",
Value: false,
Required: false,
}
var balanceCommand = cli.Command{
Name: "balance",
Usage: "Shows the onchain and offchain balance of the Ark wallet",
Action: balanceAction,
Flags: []cli.Flag{&expiryDetailsFlag},
}
func balanceAction(ctx *cli.Context) error {
computeExpiryDetails := ctx.Bool(expiryDetailsFlag.Name)
func (*clArkBitcoinCLI) Balance(ctx *cli.Context) error {
computeExpiryDetails := ctx.Bool(flags.ExpiryDetailsFlag.Name)
client, cancel, err := getClientFromState(ctx)
if err != nil {
@@ -36,10 +25,9 @@ func balanceAction(ctx *cli.Context) error {
if err != nil {
return err
}
_, network := getNetwork(ctx)
// No need to check for error here becuase this function is called also by getAddress().
// nolint:all
unilateralExitDelay, _ := getUnilateralExitDelay(ctx)
unilateralExitDelay, _ := utils.GetUnilateralExitDelay(ctx)
wg := &sync.WaitGroup{}
wg.Add(3)
@@ -47,7 +35,7 @@ func balanceAction(ctx *cli.Context) error {
chRes := make(chan balanceRes, 3)
go func() {
defer wg.Done()
explorer := NewExplorer(ctx)
explorer := utils.NewExplorer(ctx)
balance, amountByExpiration, err := getOffchainBalance(
ctx, explorer, client, offchainAddr, computeExpiryDetails,
)
@@ -61,8 +49,8 @@ func balanceAction(ctx *cli.Context) error {
go func() {
defer wg.Done()
explorer := NewExplorer(ctx)
balance, err := explorer.GetBalance(onchainAddr, network.AssetID)
explorer := utils.NewExplorer(ctx)
balance, err := explorer.GetBalance(onchainAddr.EncodeAddress(), "")
if err != nil {
chRes <- balanceRes{0, 0, nil, nil, err}
return
@@ -72,10 +60,10 @@ func balanceAction(ctx *cli.Context) error {
go func() {
defer wg.Done()
explorer := NewExplorer(ctx)
explorer := utils.NewExplorer(ctx)
spendableBalance, lockedBalance, err := explorer.GetRedeemedVtxosBalance(
redemptionAddr, unilateralExitDelay,
redemptionAddr.EncodeAddress(), unilateralExitDelay,
)
if err != nil {
chRes <- balanceRes{0, 0, nil, nil, err}
@@ -180,7 +168,7 @@ func balanceAction(ctx *cli.Context) error {
response["offchain_balance"] = offchainBalanceJSON
return printJSON(response)
return utils.PrintJSON(response)
}
type balanceRes struct {
@@ -190,3 +178,31 @@ type balanceRes struct {
offchainBalanceByExpiration map[int64]uint64
err error
}
func getOffchainBalance(
ctx *cli.Context, explorer utils.Explorer, client arkv1.ArkServiceClient,
addr string, computeExpiration bool,
) (uint64, map[int64]uint64, error) {
amountByExpiration := make(map[int64]uint64, 0)
vtxos, err := getVtxos(ctx, explorer, client, addr, computeExpiration)
if err != nil {
return 0, nil, err
}
var balance uint64
for _, vtxo := range vtxos {
balance += vtxo.amount
if vtxo.expireAt != nil {
expiration := vtxo.expireAt.Unix()
if _, ok := amountByExpiration[expiration]; !ok {
amountByExpiration[expiration] = 0
}
amountByExpiration[expiration] += vtxo.amount
}
}
return balance, amountByExpiration, nil
}

546
client/covenantless/cli.go Normal file
View File

@@ -0,0 +1,546 @@
package covenantless
import (
"fmt"
"math"
"time"
"github.com/ark-network/ark-cli/interfaces"
"github.com/ark-network/ark-cli/utils"
"github.com/ark-network/ark/common"
"github.com/ark-network/ark/common/bitcointree"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/urfave/cli/v2"
)
const dust = 450
type clArkBitcoinCLI struct{}
func (c *clArkBitcoinCLI) Receive(ctx *cli.Context) error {
offchainAddr, onchainAddr, _, err := getAddress(ctx)
if err != nil {
return err
}
return utils.PrintJSON(map[string]interface{}{
"offchain_address": offchainAddr,
"onchain_address": onchainAddr.EncodeAddress(),
})
}
func (c *clArkBitcoinCLI) Redeem(ctx *cli.Context) error {
addr := ctx.String("address")
amount := ctx.Uint64("amount")
force := ctx.Bool("force")
if len(addr) <= 0 && !force {
return fmt.Errorf("missing address flag (--address)")
}
if !force && amount <= 0 {
return fmt.Errorf("missing amount flag (--amount)")
}
client, clean, err := getClientFromState(ctx)
if err != nil {
return err
}
defer clean()
if force {
if amount > 0 {
fmt.Printf("WARNING: unilateral exit (--force) ignores --amount flag, it will redeem all your VTXOs\n")
}
return unilateralRedeem(ctx, client)
}
return collaborativeRedeem(ctx, client, addr, amount)
}
func New() interfaces.CLI {
return &clArkBitcoinCLI{}
}
type receiver struct {
To string `json:"to"`
Amount uint64 `json:"amount"`
}
func (r *receiver) isOnchain() bool {
_, err := btcutil.DecodeAddress(r.To, nil)
return err == nil
}
func sendOnchain(ctx *cli.Context, receivers []receiver) (string, error) {
ptx, err := psbt.New(nil, nil, 2, 0, nil)
if err != nil {
return "", err
}
updater, err := psbt.NewUpdater(ptx)
if err != nil {
return "", err
}
net, err := utils.GetNetwork(ctx)
if err != nil {
return "", err
}
netParams := toChainParams(net)
targetAmount := uint64(0)
for _, receiver := range receivers {
targetAmount += receiver.Amount
if receiver.Amount < dust {
return "", fmt.Errorf("invalid amount (%d), must be greater than dust %d", receiver.Amount, dust)
}
rcvAddr, err := btcutil.DecodeAddress(receiver.To, &netParams)
if err != nil {
return "", err
}
pkscript, err := txscript.PayToAddrScript(rcvAddr)
if err != nil {
return "", err
}
updater.Upsbt.UnsignedTx.AddTxOut(&wire.TxOut{
Value: int64(receiver.Amount),
PkScript: pkscript,
})
updater.Upsbt.Outputs = append(updater.Upsbt.Outputs, psbt.POutput{})
}
explorer := utils.NewExplorer(ctx)
utxos, delayedUtxos, change, err := coinSelectOnchain(
ctx, explorer, targetAmount, nil,
)
if err != nil {
return "", err
}
if err := addInputs(ctx, updater, utxos, delayedUtxos, &netParams); err != nil {
return "", err
}
if change > 0 {
_, changeAddr, _, err := getAddress(ctx)
if err != nil {
return "", err
}
pkscript, err := txscript.PayToAddrScript(changeAddr)
if err != nil {
return "", err
}
updater.Upsbt.UnsignedTx.AddTxOut(&wire.TxOut{
Value: int64(change),
PkScript: pkscript,
})
updater.Upsbt.Outputs = append(updater.Upsbt.Outputs, psbt.POutput{})
}
size := updater.Upsbt.UnsignedTx.SerializeSize()
feeRate, err := explorer.GetFeeRate()
if err != nil {
return "", err
}
feeAmount := uint64(math.Ceil(float64(size)*feeRate) + 50)
if change > feeAmount {
updater.Upsbt.UnsignedTx.TxOut[len(updater.Upsbt.Outputs)-1].Value = int64(change - feeAmount)
} else if change == feeAmount {
updater.Upsbt.UnsignedTx.TxOut = updater.Upsbt.UnsignedTx.TxOut[:len(updater.Upsbt.UnsignedTx.TxOut)-1]
} else { // change < feeAmount
if change > 0 {
updater.Upsbt.UnsignedTx.TxOut = updater.Upsbt.UnsignedTx.TxOut[:len(updater.Upsbt.UnsignedTx.TxOut)-1]
}
// reselect the difference
selected, delayedSelected, newChange, err := coinSelectOnchain(
ctx, explorer, feeAmount-change, append(utxos, delayedUtxos...),
)
if err != nil {
return "", err
}
if err := addInputs(ctx, updater, selected, delayedSelected, &netParams); err != nil {
return "", err
}
if newChange > 0 {
_, changeAddr, _, err := getAddress(ctx)
if err != nil {
return "", err
}
pkscript, err := txscript.PayToAddrScript(changeAddr)
if err != nil {
return "", err
}
updater.Upsbt.UnsignedTx.AddTxOut(&wire.TxOut{
Value: int64(newChange),
PkScript: pkscript,
})
updater.Upsbt.Outputs = append(updater.Upsbt.Outputs, psbt.POutput{})
}
}
prvKey, err := utils.PrivateKeyFromPassword(ctx)
if err != nil {
return "", err
}
if err := signPsbt(ctx, updater.Upsbt, explorer, prvKey); err != nil {
return "", err
}
for i := range updater.Upsbt.Inputs {
if err := psbt.Finalize(updater.Upsbt, i); err != nil {
return "", err
}
}
return updater.Upsbt.B64Encode()
}
func coinSelectOnchain(
ctx *cli.Context,
explorer utils.Explorer, targetAmount uint64, exclude []utils.Utxo,
) ([]utils.Utxo, []utils.Utxo, uint64, error) {
_, onchainAddr, _, err := getAddress(ctx)
if err != nil {
return nil, nil, 0, err
}
fromExplorer, err := explorer.GetUtxos(onchainAddr.EncodeAddress())
if err != nil {
return nil, nil, 0, err
}
utxos := make([]utils.Utxo, 0)
selectedAmount := uint64(0)
for _, utxo := range fromExplorer {
if selectedAmount >= targetAmount {
break
}
for _, excluded := range exclude {
if utxo.Txid == excluded.Txid && utxo.Vout == excluded.Vout {
continue
}
}
utxos = append(utxos, utxo)
selectedAmount += utxo.Amount
}
if selectedAmount >= targetAmount {
return utxos, nil, selectedAmount - targetAmount, nil
}
userPubkey, err := utils.GetWalletPublicKey(ctx)
if err != nil {
return nil, nil, 0, err
}
aspPubkey, err := utils.GetAspPublicKey(ctx)
if err != nil {
return nil, nil, 0, err
}
unilateralExitDelay, err := utils.GetUnilateralExitDelay(ctx)
if err != nil {
return nil, nil, 0, err
}
vtxoTapKey, _, err := computeVtxoTaprootScript(
userPubkey, aspPubkey, uint(unilateralExitDelay),
)
if err != nil {
return nil, nil, 0, err
}
net, err := utils.GetNetwork(ctx)
if err != nil {
return nil, nil, 0, err
}
liquidNet := toChainParams(net)
p2tr, err := btcutil.NewAddressTaproot(
schnorr.SerializePubKey(vtxoTapKey),
&liquidNet,
)
if err != nil {
return nil, nil, 0, err
}
addr := p2tr.EncodeAddress()
fromExplorer, err = explorer.GetUtxos(addr)
if err != nil {
return nil, nil, 0, err
}
delayedUtxos := make([]utils.Utxo, 0)
for _, utxo := range fromExplorer {
if selectedAmount >= targetAmount {
break
}
availableAt := time.Unix(utxo.Status.Blocktime, 0).Add(
time.Duration(unilateralExitDelay) * time.Second,
)
if availableAt.After(time.Now()) {
continue
}
for _, excluded := range exclude {
if utxo.Txid == excluded.Txid && utxo.Vout == excluded.Vout {
continue
}
}
delayedUtxos = append(delayedUtxos, utxo)
selectedAmount += utxo.Amount
}
if selectedAmount < targetAmount {
return nil, nil, 0, fmt.Errorf(
"not enough funds to cover amount %d", targetAmount,
)
}
return utxos, delayedUtxos, selectedAmount - targetAmount, nil
}
func addInputs(
ctx *cli.Context,
updater *psbt.Updater,
utxos, delayedUtxos []utils.Utxo,
net *chaincfg.Params,
) error {
_, onchainAddr, _, err := getAddress(ctx)
if err != nil {
return err
}
changeScript, err := txscript.PayToAddrScript(onchainAddr)
if err != nil {
return err
}
for _, utxo := range utxos {
previousHash, err := chainhash.NewHashFromStr(utxo.Txid)
if err != nil {
return err
}
updater.Upsbt.UnsignedTx.AddTxIn(&wire.TxIn{
PreviousOutPoint: wire.OutPoint{
Hash: *previousHash,
Index: utxo.Vout,
},
})
updater.Upsbt.Inputs = append(updater.Upsbt.Inputs, psbt.PInput{})
if err := updater.AddInWitnessUtxo(
&wire.TxOut{
Value: int64(utxo.Amount),
PkScript: changeScript,
},
len(updater.Upsbt.UnsignedTx.TxIn)-1,
); err != nil {
return err
}
}
if len(delayedUtxos) > 0 {
userPubkey, err := utils.GetWalletPublicKey(ctx)
if err != nil {
return err
}
aspPubkey, err := utils.GetAspPublicKey(ctx)
if err != nil {
return err
}
unilateralExitDelay, err := utils.GetUnilateralExitDelay(ctx)
if err != nil {
return err
}
vtxoTapKey, leafProof, err := computeVtxoTaprootScript(
userPubkey, aspPubkey, uint(unilateralExitDelay),
)
if err != nil {
return err
}
p2tr, err := btcutil.NewAddressTaproot(schnorr.SerializePubKey(vtxoTapKey), net)
if err != nil {
return err
}
script, err := txscript.PayToAddrScript(p2tr)
if err != nil {
return err
}
for _, utxo := range delayedUtxos {
previousHash, err := chainhash.NewHashFromStr(utxo.Txid)
if err != nil {
return err
}
if err := addVtxoInput(
updater,
&wire.OutPoint{
Hash: *previousHash,
Index: utxo.Vout,
},
uint(unilateralExitDelay),
leafProof,
); err != nil {
return err
}
if err := updater.AddInWitnessUtxo(
&wire.TxOut{
Value: int64(utxo.Amount),
PkScript: script,
},
len(updater.Upsbt.Inputs)-1,
); err != nil {
return err
}
}
}
return nil
}
func decodeReceiverAddress(addr string) (
bool, []byte, *secp256k1.PublicKey, error,
) {
decoded, err := btcutil.DecodeAddress(addr, nil)
if err != nil {
_, userPubkey, _, err := common.DecodeAddress(addr)
if err != nil {
return false, nil, nil, err
}
return false, nil, userPubkey, nil
}
pkscript, err := txscript.PayToAddrScript(decoded)
if err != nil {
return false, nil, nil, err
}
return true, pkscript, nil, nil
}
func addVtxoInput(
updater *psbt.Updater, inputArgs *wire.OutPoint, exitDelay uint,
tapLeafProof *txscript.TapscriptProof,
) error {
sequence, err := common.BIP68EncodeAsNumber(exitDelay)
if err != nil {
return nil
}
nextInputIndex := len(updater.Upsbt.Inputs)
updater.Upsbt.UnsignedTx.AddTxIn(&wire.TxIn{
PreviousOutPoint: *inputArgs,
Sequence: sequence,
})
updater.Upsbt.Inputs = append(updater.Upsbt.Inputs, psbt.PInput{})
controlBlock := tapLeafProof.ToControlBlock(bitcointree.UnspendableKey())
controlBlockBytes, err := controlBlock.ToBytes()
if err != nil {
return err
}
updater.Upsbt.Inputs[nextInputIndex].TaprootLeafScript = []*psbt.TaprootTapLeafScript{
{
ControlBlock: controlBlockBytes,
Script: tapLeafProof.Script,
LeafVersion: tapLeafProof.LeafVersion,
},
}
return nil
}
func getAddress(ctx *cli.Context) (offchainAddr string, onchainAddr, redemptionAddr btcutil.Address, err error) {
userPubkey, err := utils.GetWalletPublicKey(ctx)
if err != nil {
return
}
aspPubkey, err := utils.GetAspPublicKey(ctx)
if err != nil {
return
}
unilateralExitDelay, err := utils.GetUnilateralExitDelay(ctx)
if err != nil {
return
}
arkNet, err := utils.GetNetwork(ctx)
if err != nil {
return
}
arkAddr, err := common.EncodeAddress(arkNet.Addr, userPubkey, aspPubkey)
if err != nil {
return
}
netParams := toChainParams(arkNet)
p2wpkh, err := btcutil.NewAddressWitnessPubKeyHash(btcutil.Hash160(userPubkey.SerializeCompressed()), &netParams)
if err != nil {
return
}
vtxoTapKey, _, err := computeVtxoTaprootScript(
userPubkey, aspPubkey, uint(unilateralExitDelay),
)
if err != nil {
return
}
p2tr, err := btcutil.NewAddressTaproot(
schnorr.SerializePubKey(vtxoTapKey),
&netParams,
)
if err != nil {
return
}
redemptionAddr = p2tr
onchainAddr = p2wpkh
offchainAddr = arkAddr
return
}

View File

@@ -0,0 +1,512 @@
package covenantless
import (
"bytes"
"context"
"fmt"
"io"
"strings"
"time"
"github.com/ark-network/ark-cli/utils"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common/bitcointree"
"github.com/ark-network/ark/common/tree"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/urfave/cli/v2"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)
type vtxo struct {
amount uint64
txid string
vout uint32
poolTxid string
expireAt *time.Time
}
func getVtxos(
ctx *cli.Context, explorer utils.Explorer, client arkv1.ArkServiceClient,
addr string, computeExpiration bool,
) ([]vtxo, error) {
response, err := client.ListVtxos(ctx.Context, &arkv1.ListVtxosRequest{
Address: addr,
})
if err != nil {
return nil, err
}
vtxos := make([]vtxo, 0, len(response.GetSpendableVtxos()))
for _, v := range response.GetSpendableVtxos() {
var expireAt *time.Time
if v.ExpireAt > 0 {
t := time.Unix(v.ExpireAt, 0)
expireAt = &t
}
if v.Swept {
continue
}
vtxos = append(vtxos, vtxo{
amount: v.Receiver.Amount,
txid: v.Outpoint.Txid,
vout: v.Outpoint.Vout,
poolTxid: v.PoolTxid,
expireAt: expireAt,
})
}
if !computeExpiration {
return vtxos, nil
}
redeemBranches, err := getRedeemBranches(ctx.Context, explorer, client, vtxos)
if err != nil {
return nil, err
}
for vtxoTxid, branch := range redeemBranches {
expiration, err := branch.expireAt(ctx)
if err != nil {
return nil, err
}
for i, vtxo := range vtxos {
if vtxo.txid == vtxoTxid {
vtxos[i].expireAt = expiration
break
}
}
}
return vtxos, nil
}
func getClientFromState(ctx *cli.Context) (arkv1.ArkServiceClient, func(), error) {
state, err := utils.GetState(ctx)
if err != nil {
return nil, nil, err
}
addr := state[utils.ASP_URL]
if len(addr) <= 0 {
return nil, nil, fmt.Errorf("missing asp url")
}
return getClient(addr)
}
func getClient(addr string) (arkv1.ArkServiceClient, func(), error) {
creds := insecure.NewCredentials()
port := 80
if strings.HasPrefix(addr, "https://") {
addr = strings.TrimPrefix(addr, "https://")
creds = credentials.NewTLS(nil)
port = 443
}
if !strings.Contains(addr, ":") {
addr = fmt.Sprintf("%s:%d", addr, port)
}
conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(creds))
if err != nil {
return nil, nil, err
}
client := arkv1.NewArkServiceClient(conn)
closeFn := func() {
err := conn.Close()
if err != nil {
fmt.Printf("error closing connection: %s\n", err)
}
}
return client, closeFn, nil
}
func getRedeemBranches(
ctx context.Context, explorer utils.Explorer, client arkv1.ArkServiceClient,
vtxos []vtxo,
) (map[string]*redeemBranch, error) {
congestionTrees := make(map[string]tree.CongestionTree, 0)
redeemBranches := make(map[string]*redeemBranch, 0)
for _, vtxo := range vtxos {
if _, ok := congestionTrees[vtxo.poolTxid]; !ok {
round, err := client.GetRound(ctx, &arkv1.GetRoundRequest{
Txid: vtxo.poolTxid,
})
if err != nil {
return nil, err
}
treeFromRound := round.GetRound().GetCongestionTree()
congestionTree, err := toCongestionTree(treeFromRound)
if err != nil {
return nil, err
}
congestionTrees[vtxo.poolTxid] = congestionTree
}
redeemBranch, err := newRedeemBranch(
explorer, congestionTrees[vtxo.poolTxid], vtxo,
)
if err != nil {
return nil, err
}
redeemBranches[vtxo.txid] = redeemBranch
}
return redeemBranches, nil
}
func toCongestionTree(treeFromProto *arkv1.Tree) (tree.CongestionTree, error) {
levels := make(tree.CongestionTree, 0, len(treeFromProto.Levels))
for _, level := range treeFromProto.Levels {
nodes := make([]tree.Node, 0, len(level.Nodes))
for _, node := range level.Nodes {
nodes = append(nodes, tree.Node{
Txid: node.Txid,
Tx: node.Tx,
ParentTxid: node.ParentTxid,
Leaf: false,
})
}
levels = append(levels, nodes)
}
for j, treeLvl := range levels {
for i, node := range treeLvl {
if len(levels.Children(node.Txid)) == 0 {
levels[j][i].Leaf = true
}
}
}
return levels, nil
}
// castCongestionTree converts a tree.CongestionTree to a repeated arkv1.TreeLevel
func castCongestionTree(congestionTree tree.CongestionTree) *arkv1.Tree {
levels := make([]*arkv1.TreeLevel, 0, len(congestionTree))
for _, level := range congestionTree {
levelProto := &arkv1.TreeLevel{
Nodes: make([]*arkv1.Node, 0, len(level)),
}
for _, node := range level {
levelProto.Nodes = append(levelProto.Nodes, &arkv1.Node{
Txid: node.Txid,
Tx: node.Tx,
ParentTxid: node.ParentTxid,
})
}
levels = append(levels, levelProto)
}
return &arkv1.Tree{
Levels: levels,
}
}
func handleRoundStream(
ctx *cli.Context, client arkv1.ArkServiceClient, paymentID string,
vtxosToSign []vtxo, secKey *secp256k1.PrivateKey, receivers []*arkv1.Output,
) (poolTxID string, err error) {
stream, err := client.GetEventStream(ctx.Context, &arkv1.GetEventStreamRequest{})
if err != nil {
return "", err
}
var pingStop func()
pingReq := &arkv1.PingRequest{
PaymentId: paymentID,
}
for pingStop == nil {
pingStop = ping(ctx.Context, client, pingReq)
}
defer pingStop()
for {
event, err := stream.Recv()
if err == io.EOF {
break
}
if err != nil {
return "", err
}
if e := event.GetRoundFailed(); e != nil {
pingStop()
return "", fmt.Errorf("round failed: %s", e.GetReason())
}
if e := event.GetRoundFinalization(); e != nil {
// stop pinging as soon as we receive some forfeit txs
pingStop()
poolTx := e.GetPoolTx()
ptx, err := psbt.NewFromRawBytes(strings.NewReader(poolTx), true)
if err != nil {
return "", err
}
congestionTree, err := toCongestionTree(e.GetCongestionTree())
if err != nil {
return "", err
}
connectors := e.GetConnectors()
aspPubkey, err := utils.GetAspPublicKey(ctx)
if err != nil {
return "", err
}
roundLifetime, err := utils.GetRoundLifetime(ctx)
if err != nil {
return "", err
}
minRelayFee, err := utils.GetMinRelayFee(ctx)
if err != nil {
return "", err
}
if !isOnchainOnly(receivers) {
if err := bitcointree.ValidateCongestionTree(
congestionTree, poolTx, aspPubkey, int64(roundLifetime), int64(minRelayFee),
); err != nil {
return "", err
}
}
// TODO bitcoin validateConnectors
// if err := common.ValidateConnectors(poolTx, connectors); err != nil {
// return "", err
// }
unilateralExitDelay, err := utils.GetUnilateralExitDelay(ctx)
if err != nil {
return "", err
}
for _, receiver := range receivers {
isOnChain, onchainScript, userPubkey, err := decodeReceiverAddress(
receiver.Address,
)
if err != nil {
return "", err
}
if isOnChain {
// collaborative exit case
// search for the output in the pool tx
found := false
for _, output := range ptx.UnsignedTx.TxOut {
if bytes.Equal(output.PkScript, onchainScript) {
if output.Value != int64(receiver.Amount) {
return "", fmt.Errorf(
"invalid collaborative exit output amount: got %d, want %d",
output.Value, receiver.Amount,
)
}
found = true
break
}
}
if !found {
return "", fmt.Errorf(
"collaborative exit output not found: %s", receiver.Address,
)
}
continue
}
// off-chain send case
// search for the output in congestion tree
found := false
// compute the receiver output taproot key
outputTapKey, _, err := computeVtxoTaprootScript(
userPubkey, aspPubkey, uint(unilateralExitDelay),
)
if err != nil {
return "", err
}
leaves := congestionTree.Leaves()
for _, leaf := range leaves {
tx, err := psbt.NewFromRawBytes(strings.NewReader(leaf.Tx), true)
if err != nil {
return "", err
}
for _, output := range tx.UnsignedTx.TxOut {
if len(output.PkScript) == 0 {
continue
}
if bytes.Equal(
output.PkScript[2:], schnorr.SerializePubKey(outputTapKey),
) {
if output.Value != int64(receiver.Amount) {
continue
}
found = true
break
}
}
if found {
break
}
}
if !found {
return "", fmt.Errorf(
"off-chain send output not found: %s", receiver.Address,
)
}
}
fmt.Println("congestion tree validated")
forfeits := e.GetForfeitTxs()
signedForfeits := make([]string, 0)
fmt.Print("signing forfeit txs... ")
explorer := utils.NewExplorer(ctx)
connectorsTxids := make([]string, 0, len(connectors))
for _, connector := range connectors {
p, err := psbt.NewFromRawBytes(strings.NewReader(connector), true)
if err != nil {
return "", err
}
txid := p.UnsignedTx.TxHash().String()
connectorsTxids = append(connectorsTxids, txid)
}
for _, forfeit := range forfeits {
ptx, err := psbt.NewFromRawBytes(strings.NewReader(forfeit), true)
if err != nil {
return "", err
}
for _, input := range ptx.UnsignedTx.TxIn {
inputTxid := input.PreviousOutPoint.Hash.String()
for _, coin := range vtxosToSign {
// check if it contains one of the input to sign
if inputTxid == coin.txid {
// verify that the connector is in the connectors list
connectorTxid := ptx.UnsignedTx.TxIn[0].PreviousOutPoint.Hash.String()
connectorFound := false
for _, txid := range connectorsTxids {
if txid == connectorTxid {
connectorFound = true
break
}
}
if !connectorFound {
return "", fmt.Errorf("connector txid %s not found in the connectors list", connectorTxid)
}
if err := signPsbt(ctx, ptx, explorer, secKey); err != nil {
return "", err
}
signedPset, err := ptx.B64Encode()
if err != nil {
return "", err
}
signedForfeits = append(signedForfeits, signedPset)
}
}
}
}
// if no forfeit txs have been signed, start pinging again and wait for the next round
if len(signedForfeits) == 0 {
fmt.Printf("\nno forfeit txs to sign, waiting for the next round...\n")
pingStop = nil
for pingStop == nil {
pingStop = ping(ctx.Context, client, pingReq)
}
continue
}
fmt.Printf("%d signed\n", len(signedForfeits))
fmt.Print("finalizing payment... ")
_, err = client.FinalizePayment(ctx.Context, &arkv1.FinalizePaymentRequest{
SignedForfeitTxs: signedForfeits,
})
if err != nil {
return "", err
}
fmt.Print("done.\n")
fmt.Println("waiting for round finalization...")
continue
}
if event.GetRoundFinalized() != nil {
return event.GetRoundFinalized().GetPoolTxid(), nil
}
}
return "", fmt.Errorf("stream closed unexpectedly")
}
// send 1 ping message every 5 seconds to signal to the ark service that we are still alive
// returns a function that can be used to stop the pinging
func ping(
ctx context.Context, client arkv1.ArkServiceClient, req *arkv1.PingRequest,
) func() {
_, err := client.Ping(ctx, req)
if err != nil {
return nil
}
ticker := time.NewTicker(5 * time.Second)
go func(t *time.Ticker) {
for range t.C {
// nolint
client.Ping(ctx, req)
}
}(ticker)
return ticker.Stop
}
func isOnchainOnly(receivers []*arkv1.Output) bool {
for _, receiver := range receivers {
isOnChain, _, _, err := decodeReceiverAddress(receiver.Address)
if err != nil {
continue
}
if !isOnChain {
return false
}
}
return true
}

126
client/covenantless/init.go Normal file
View File

@@ -0,0 +1,126 @@
package covenantless
import (
"encoding/hex"
"fmt"
"strconv"
"strings"
"github.com/ark-network/ark-cli/utils"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/urfave/cli/v2"
)
var explorerUrls = map[string]string{
common.Bitcoin.Name: "https://blockstream.info/api",
common.BitcoinTestNet.Name: "https://blockstream.info/testnet/api",
common.BitcoinRegTest.Name: "http://localhost:3000",
}
func (c *clArkBitcoinCLI) Init(ctx *cli.Context) error {
key := ctx.String("prvkey")
net := strings.ToLower(ctx.String("network"))
url := ctx.String("ark-url")
explorer := ctx.String("explorer")
var explorerURL string
if len(url) <= 0 {
return fmt.Errorf("invalid ark url")
}
if net != common.Bitcoin.Name && net != common.BitcoinTestNet.Name && net != common.BitcoinRegTest.Name {
return fmt.Errorf("invalid network")
}
if len(explorer) > 0 {
explorerURL = explorer
} else {
explorerURL = explorerUrls[net]
}
if err := connectToAsp(ctx, net, url, explorerURL); err != nil {
return err
}
password, err := utils.ReadPassword(ctx, false)
if err != nil {
return err
}
return initWallet(ctx, key, password)
}
func generateRandomPrivateKey() (*secp256k1.PrivateKey, error) {
privKey, err := btcec.NewPrivateKey()
if err != nil {
return nil, err
}
return privKey, nil
}
func connectToAsp(ctx *cli.Context, net, url, explorer string) error {
client, close, err := getClient(url)
if err != nil {
return err
}
defer close()
resp, err := client.GetInfo(ctx.Context, &arkv1.GetInfoRequest{})
if err != nil {
return err
}
return utils.SetState(ctx, map[string]string{
utils.ASP_URL: url,
utils.NETWORK: net,
utils.ASP_PUBKEY: resp.Pubkey,
utils.ROUND_LIFETIME: strconv.Itoa(int(resp.GetRoundLifetime())),
utils.UNILATERAL_EXIT_DELAY: strconv.Itoa(int(resp.GetUnilateralExitDelay())),
utils.MIN_RELAY_FEE: strconv.Itoa(int(resp.MinRelayFee)),
utils.EXPLORER: explorer,
})
}
func initWallet(ctx *cli.Context, key string, password []byte) error {
var privateKey *secp256k1.PrivateKey
if len(key) <= 0 {
privKey, err := generateRandomPrivateKey()
if err != nil {
return err
}
privateKey = privKey
} else {
privKeyBytes, err := hex.DecodeString(key)
if err != nil {
return err
}
privateKey = secp256k1.PrivKeyFromBytes(privKeyBytes)
}
cypher := utils.NewAES128Cypher()
buf := privateKey.Serialize()
encryptedPrivateKey, err := cypher.Encrypt(buf, password)
if err != nil {
return err
}
passwordHash := utils.HashPassword([]byte(password))
pubkey := privateKey.PubKey().SerializeCompressed()
state := map[string]string{
utils.ENCRYPTED_PRVKEY: hex.EncodeToString(encryptedPrivateKey),
utils.PASSWORD_HASH: hex.EncodeToString(passwordHash),
utils.PUBKEY: hex.EncodeToString(pubkey),
}
if err := utils.SetState(ctx, state); err != nil {
return err
}
fmt.Println("wallet initialized")
return nil
}

View File

@@ -0,0 +1,19 @@
package covenantless
import (
"github.com/ark-network/ark/common"
"github.com/btcsuite/btcd/chaincfg"
)
func toChainParams(net *common.Network) chaincfg.Params {
switch net.Name {
case common.Bitcoin.Name:
return chaincfg.MainNetParams
case common.BitcoinTestNet.Name:
return chaincfg.TestNet3Params
case common.BitcoinRegTest.Name:
return chaincfg.RegressionNetParams
default:
return chaincfg.MainNetParams
}
}

View File

@@ -0,0 +1,216 @@
package covenantless
import (
"encoding/hex"
"fmt"
"strings"
"github.com/ark-network/ark-cli/utils"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common/bitcointree"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/urfave/cli/v2"
)
func (c *clArkBitcoinCLI) Onboard(ctx *cli.Context) error {
isTrusted := ctx.Bool("trusted")
amount := ctx.Uint64("amount")
if !isTrusted && amount <= 0 {
return fmt.Errorf("missing amount flag (--amount)")
}
net, err := utils.GetNetwork(ctx)
if err != nil {
return err
}
userPubKey, err := utils.GetWalletPublicKey(ctx)
if err != nil {
return err
}
client, cancel, err := getClientFromState(ctx)
if err != nil {
return err
}
defer cancel()
if isTrusted {
resp, err := client.TrustedOnboarding(ctx.Context, &arkv1.TrustedOnboardingRequest{
UserPubkey: hex.EncodeToString(userPubKey.SerializeCompressed()),
})
if err != nil {
return err
}
return utils.PrintJSON(map[string]interface{}{
"onboard_address": resp.Address,
})
}
aspPubkey, err := utils.GetAspPublicKey(ctx)
if err != nil {
return err
}
roundLifetime, err := utils.GetRoundLifetime(ctx)
if err != nil {
return err
}
unilateralExitDelay, err := utils.GetUnilateralExitDelay(ctx)
if err != nil {
return err
}
minRelayFee, err := utils.GetMinRelayFee(ctx)
if err != nil {
return err
}
congestionTreeLeaf := bitcointree.Receiver{
Pubkey: hex.EncodeToString(userPubKey.SerializeCompressed()),
Amount: uint64(amount), // Convert amount to uint64
}
leaves := []bitcointree.Receiver{congestionTreeLeaf}
ephemeralKey, err := secp256k1.GeneratePrivateKey()
if err != nil {
return err
}
cosigners := []*secp256k1.PublicKey{ephemeralKey.PubKey()} // TODO asp as cosigner
sharedOutputScript, sharedOutputAmount, err := bitcointree.CraftSharedOutput(
cosigners,
aspPubkey,
leaves,
uint64(minRelayFee),
roundLifetime,
unilateralExitDelay,
)
if err != nil {
return err
}
netParams := toChainParams(net)
address, err := btcutil.NewAddressTaproot(sharedOutputScript[2:], &netParams)
if err != nil {
return err
}
onchainReceiver := receiver{
To: address.EncodeAddress(),
Amount: uint64(sharedOutputAmount),
}
partialTx, err := sendOnchain(ctx, []receiver{onchainReceiver})
if err != nil {
return err
}
ptx, err := psbt.NewFromRawBytes(strings.NewReader(partialTx), true)
if err != nil {
return err
}
txid := ptx.UnsignedTx.TxHash().String()
congestionTree, err := bitcointree.CraftCongestionTree(
&wire.OutPoint{
Hash: ptx.UnsignedTx.TxHash(),
Index: 0,
},
cosigners,
aspPubkey,
leaves,
uint64(minRelayFee),
roundLifetime,
unilateralExitDelay,
)
if err != nil {
return err
}
sweepClosure := bitcointree.CSVSigClosure{
Pubkey: aspPubkey,
Seconds: uint(roundLifetime),
}
sweepTapLeaf, err := sweepClosure.Leaf()
if err != nil {
return err
}
sweepTapTree := txscript.AssembleTaprootScriptTree(*sweepTapLeaf)
root := sweepTapTree.RootNode.TapHash()
signer := bitcointree.NewTreeSignerSession(
ephemeralKey,
congestionTree,
minRelayFee,
root.CloneBytes(),
)
nonces, err := signer.GetNonces() // TODO send nonces to ASP
if err != nil {
return err
}
coordinator, err := bitcointree.NewTreeCoordinatorSession(
congestionTree,
minRelayFee,
root.CloneBytes(),
cosigners,
)
if err != nil {
return err
}
if err := coordinator.AddNonce(ephemeralKey.PubKey(), nonces); err != nil {
return err
}
aggregatedNonces, err := coordinator.AggregateNonces()
if err != nil {
return err
}
if err := signer.SetKeys(cosigners, aggregatedNonces); err != nil {
return err
}
sigs, err := signer.Sign()
if err != nil {
return err
}
if err := coordinator.AddSig(ephemeralKey.PubKey(), sigs); err != nil {
return err
}
signedTree, err := coordinator.SignTree()
if err != nil {
return err
}
_, err = client.Onboard(ctx.Context, &arkv1.OnboardRequest{
BoardingTx: partialTx,
CongestionTree: castCongestionTree(signedTree),
UserPubkey: hex.EncodeToString(userPubKey.SerializeCompressed()),
})
if err != nil {
return err
}
fmt.Println("onboard_txid:", txid)
return nil
}

View File

@@ -0,0 +1,206 @@
package covenantless
import (
"bufio"
"fmt"
"log"
"os"
"strings"
"time"
"github.com/ark-network/ark-cli/utils"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/btcsuite/btcd/btcutil"
"github.com/urfave/cli/v2"
)
func collaborativeRedeem(
ctx *cli.Context, client arkv1.ArkServiceClient, addr string, amount uint64,
) error {
withExpiryCoinselect := ctx.Bool("enable-expiry-coinselect")
_, err := btcutil.DecodeAddress(addr, nil)
if err != nil {
return fmt.Errorf("invalid onchain address")
}
netinstate, err := utils.GetNetwork(ctx)
if err != nil {
return err
}
netParams := toChainParams(netinstate)
if netinstate.Name != netParams.Name {
return fmt.Errorf("invalid onchain address: must be for %s network", netParams.Name)
}
offchainAddr, _, _, err := getAddress(ctx)
if err != nil {
return err
}
receivers := []*arkv1.Output{
{
Address: addr,
Amount: amount,
},
}
explorer := utils.NewExplorer(ctx)
vtxos, err := getVtxos(ctx, explorer, client, offchainAddr, withExpiryCoinselect)
if err != nil {
return err
}
selectedCoins, changeAmount, err := coinSelect(vtxos, amount, withExpiryCoinselect)
if err != nil {
return err
}
if changeAmount > 0 {
receivers = append(receivers, &arkv1.Output{
Address: offchainAddr,
Amount: changeAmount,
})
}
inputs := make([]*arkv1.Input, 0, len(selectedCoins))
for _, coin := range selectedCoins {
inputs = append(inputs, &arkv1.Input{
Txid: coin.txid,
Vout: coin.vout,
})
}
secKey, err := utils.PrivateKeyFromPassword(ctx)
if err != nil {
return err
}
registerResponse, err := client.RegisterPayment(ctx.Context, &arkv1.RegisterPaymentRequest{
Inputs: inputs,
})
if err != nil {
return err
}
_, err = client.ClaimPayment(ctx.Context, &arkv1.ClaimPaymentRequest{
Id: registerResponse.GetId(),
Outputs: receivers,
})
if err != nil {
return err
}
poolTxID, err := handleRoundStream(
ctx,
client,
registerResponse.GetId(),
selectedCoins,
secKey,
receivers,
)
if err != nil {
return err
}
return utils.PrintJSON(map[string]interface{}{
"pool_txid": poolTxID,
})
}
func unilateralRedeem(ctx *cli.Context, client arkv1.ArkServiceClient) error {
offchainAddr, _, _, err := getAddress(ctx)
if err != nil {
return err
}
explorer := utils.NewExplorer(ctx)
vtxos, err := getVtxos(ctx, explorer, client, offchainAddr, false)
if err != nil {
return err
}
totalVtxosAmount := uint64(0)
for _, vtxo := range vtxos {
totalVtxosAmount += vtxo.amount
}
if len(ctx.String("password")) == 0 {
ok := askForConfirmation(fmt.Sprintf("redeem %d sats ?", totalVtxosAmount))
if !ok {
return fmt.Errorf("aborting unilateral exit")
}
}
// transactionsMap avoid duplicates
transactionsMap := make(map[string]struct{}, 0)
transactions := make([]string, 0)
redeemBranches, err := getRedeemBranches(ctx.Context, explorer, client, vtxos)
if err != nil {
return err
}
for _, branch := range redeemBranches {
branchTxs, err := branch.redeemPath()
if err != nil {
return err
}
for _, txHex := range branchTxs {
if _, ok := transactionsMap[txHex]; !ok {
transactions = append(transactions, txHex)
transactionsMap[txHex] = struct{}{}
}
}
}
for i, txHex := range transactions {
for {
txid, err := explorer.Broadcast(txHex)
if err != nil {
if strings.Contains(strings.ToLower(err.Error()), "bad-txns-inputs-missingorspent") {
time.Sleep(1 * time.Second)
} else {
fmt.Printf("error broadcasting tx %s: %s\n", txHex, err)
return err
}
}
if len(txid) > 0 {
fmt.Printf("(%d/%d) broadcasted tx %s\n", i+1, len(transactions), txid)
break
}
}
}
return nil
}
// askForConfirmation asks the user for confirmation. A user must type in "yes" or "no" and then press enter.
// if the input is not recognized, it will ask again.
func askForConfirmation(s string) bool {
reader := bufio.NewReader(os.Stdin)
for {
fmt.Printf("%s [y/n]: ", s)
response, err := reader.ReadString('\n')
if err != nil {
log.Fatal(err)
}
response = strings.ToLower(strings.TrimSpace(response))
if response == "y" || response == "yes" {
return true
} else if response == "n" || response == "no" {
return false
}
}
}

View File

@@ -0,0 +1,194 @@
package covenantless
import (
"bytes"
"encoding/hex"
"fmt"
"strings"
"time"
"github.com/ark-network/ark-cli/utils"
"github.com/ark-network/ark/common/bitcointree"
"github.com/ark-network/ark/common/tree"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/txscript"
"github.com/urfave/cli/v2"
)
type redeemBranch struct {
vtxo *vtxo
branch []*psbt.Packet
lifetime time.Duration
explorer utils.Explorer
}
func newRedeemBranch(
explorer utils.Explorer,
congestionTree tree.CongestionTree, vtxo vtxo,
) (*redeemBranch, error) {
_, seconds, err := findSweepClosure(congestionTree)
if err != nil {
return nil, err
}
lifetime, err := time.ParseDuration(fmt.Sprintf("%ds", seconds))
if err != nil {
return nil, err
}
nodes, err := congestionTree.Branch(vtxo.txid)
if err != nil {
return nil, err
}
branch := make([]*psbt.Packet, 0, len(nodes))
for _, node := range nodes {
ptx, err := psbt.NewFromRawBytes(strings.NewReader(node.Tx), true)
if err != nil {
return nil, err
}
branch = append(branch, ptx)
}
return &redeemBranch{
vtxo: &vtxo,
branch: branch,
lifetime: lifetime,
explorer: explorer,
}, nil
}
// RedeemPath returns the list of transactions to broadcast in order to access the vtxo output
func (r *redeemBranch) redeemPath() ([]string, error) {
transactions := make([]string, 0, len(r.branch))
offchainPath, err := r.offchainPath()
if err != nil {
return nil, err
}
for _, ptx := range offchainPath {
firstInput := ptx.Inputs[0]
if len(firstInput.TaprootKeySpendSig) == 0 {
return nil, fmt.Errorf("missing taproot key spend signature")
}
var witness bytes.Buffer
if err := psbt.WriteTxWitness(&witness, [][]byte{firstInput.TaprootKeySpendSig}); err != nil {
return nil, err
}
ptx.Inputs[0].FinalScriptWitness = witness.Bytes()
extracted, err := psbt.Extract(ptx)
if err != nil {
return nil, err
}
var txBytes bytes.Buffer
if err := extracted.Serialize(&txBytes); err != nil {
return nil, err
}
transactions = append(transactions, hex.EncodeToString(txBytes.Bytes()))
}
return transactions, nil
}
func (r *redeemBranch) expireAt(*cli.Context) (*time.Time, error) {
lastKnownBlocktime := int64(0)
confirmed, blocktime, _ := r.explorer.GetTxBlocktime(r.vtxo.poolTxid)
if confirmed {
lastKnownBlocktime = blocktime
} else {
expirationFromNow := time.Now().Add(time.Minute).Add(r.lifetime)
return &expirationFromNow, nil
}
for _, ptx := range r.branch {
txid := ptx.UnsignedTx.TxHash().String()
confirmed, blocktime, err := r.explorer.GetTxBlocktime(txid)
if err != nil {
break
}
if confirmed {
lastKnownBlocktime = blocktime
continue
}
break
}
t := time.Unix(lastKnownBlocktime, 0).Add(r.lifetime)
return &t, nil
}
// offchainPath checks for transactions of the branch onchain and returns only the offchain part
func (r *redeemBranch) offchainPath() ([]*psbt.Packet, error) {
offchainPath := append([]*psbt.Packet{}, r.branch...)
for i := len(r.branch) - 1; i >= 0; i-- {
ptx := r.branch[i]
txHash := ptx.UnsignedTx.TxHash().String()
if _, err := r.explorer.GetTxHex(txHash); err != nil {
continue
}
// if no error, the tx exists onchain, so we can remove it (+ the parents) from the branch
if i == len(r.branch)-1 {
offchainPath = []*psbt.Packet{}
} else {
offchainPath = r.branch[i+1:]
}
break
}
return offchainPath, nil
}
func findSweepClosure(
congestionTree tree.CongestionTree,
) (*txscript.TapLeaf, uint, error) {
root, err := congestionTree.Root()
if err != nil {
return nil, 0, err
}
// find the sweep closure
tx, err := psbt.NewFromRawBytes(strings.NewReader(root.Tx), true)
if err != nil {
fmt.Println("find sweep closure error")
return nil, 0, err
}
var seconds uint
var sweepClosure *txscript.TapLeaf
for _, tapLeaf := range tx.Inputs[0].TaprootLeafScript {
closure := &bitcointree.CSVSigClosure{}
valid, err := closure.Decode(tapLeaf.Script)
if err != nil {
continue
}
if valid && closure.Seconds > seconds {
seconds = closure.Seconds
leaf := txscript.NewBaseTapLeaf(tapLeaf.Script)
sweepClosure = &leaf
}
}
if sweepClosure == nil {
return nil, 0, fmt.Errorf("sweep closure not found")
}
return sweepClosure, seconds, nil
}

224
client/covenantless/send.go Normal file
View File

@@ -0,0 +1,224 @@
package covenantless
import (
"bytes"
"encoding/json"
"fmt"
"sort"
"github.com/ark-network/ark-cli/utils"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common"
"github.com/urfave/cli/v2"
)
func (c *clArkBitcoinCLI) Send(ctx *cli.Context) error {
if !ctx.IsSet("receivers") && !ctx.IsSet("to") && !ctx.IsSet("amount") {
return fmt.Errorf("missing destination, either use --to and --amount to send or --receivers to send to many")
}
receivers := ctx.String("receivers")
to := ctx.String("to")
amount := ctx.Uint64("amount")
var receiversJSON []receiver
if len(receivers) > 0 {
if err := json.Unmarshal([]byte(receivers), &receiversJSON); err != nil {
return fmt.Errorf("invalid receivers: %s", err)
}
} else {
receiversJSON = []receiver{
{
To: to,
Amount: amount,
},
}
}
if len(receiversJSON) <= 0 {
return fmt.Errorf("no receivers specified")
}
onchainReceivers := make([]receiver, 0)
offchainReceivers := make([]receiver, 0)
for _, receiver := range receiversJSON {
if receiver.isOnchain() {
onchainReceivers = append(onchainReceivers, receiver)
} else {
offchainReceivers = append(offchainReceivers, receiver)
}
}
explorer := utils.NewExplorer(ctx)
if len(onchainReceivers) > 0 {
pset, err := sendOnchain(ctx, onchainReceivers)
if err != nil {
return err
}
txid, err := explorer.Broadcast(pset)
if err != nil {
return err
}
return utils.PrintJSON(map[string]interface{}{
"txid": txid,
})
}
if len(offchainReceivers) > 0 {
if err := sendOffchain(ctx, offchainReceivers); err != nil {
return err
}
}
return nil
}
func sendOffchain(ctx *cli.Context, receivers []receiver) error {
withExpiryCoinselect := ctx.Bool("enable-expiry-coinselect")
offchainAddr, _, _, err := getAddress(ctx)
if err != nil {
return err
}
_, _, aspPubKey, err := common.DecodeAddress(offchainAddr)
if err != nil {
return err
}
receiversOutput := make([]*arkv1.Output, 0)
sumOfReceivers := uint64(0)
for _, receiver := range receivers {
_, _, aspKey, err := common.DecodeAddress(receiver.To)
if err != nil {
return fmt.Errorf("invalid receiver address: %s", err)
}
if !bytes.Equal(
aspPubKey.SerializeCompressed(), aspKey.SerializeCompressed(),
) {
return fmt.Errorf("invalid receiver address '%s': must be associated with the connected service provider", receiver.To)
}
if receiver.Amount < dust {
return fmt.Errorf("invalid amount (%d), must be greater than dust %d", receiver.Amount, dust)
}
receiversOutput = append(receiversOutput, &arkv1.Output{
Address: receiver.To,
Amount: uint64(receiver.Amount),
})
sumOfReceivers += receiver.Amount
}
client, close, err := getClientFromState(ctx)
if err != nil {
return err
}
defer close()
explorer := utils.NewExplorer(ctx)
vtxos, err := getVtxos(ctx, explorer, client, offchainAddr, withExpiryCoinselect)
if err != nil {
return err
}
selectedCoins, changeAmount, err := coinSelect(vtxos, sumOfReceivers, withExpiryCoinselect)
if err != nil {
return err
}
if changeAmount > 0 {
changeReceiver := &arkv1.Output{
Address: offchainAddr,
Amount: changeAmount,
}
receiversOutput = append(receiversOutput, changeReceiver)
}
inputs := make([]*arkv1.Input, 0, len(selectedCoins))
for _, coin := range selectedCoins {
inputs = append(inputs, &arkv1.Input{
Txid: coin.txid,
Vout: coin.vout,
})
}
secKey, err := utils.PrivateKeyFromPassword(ctx)
if err != nil {
return err
}
registerResponse, err := client.RegisterPayment(
ctx.Context, &arkv1.RegisterPaymentRequest{Inputs: inputs},
)
if err != nil {
return err
}
_, err = client.ClaimPayment(ctx.Context, &arkv1.ClaimPaymentRequest{
Id: registerResponse.GetId(),
Outputs: receiversOutput,
})
if err != nil {
return err
}
poolTxID, err := handleRoundStream(
ctx, client, registerResponse.GetId(),
selectedCoins, secKey, receiversOutput,
)
if err != nil {
return err
}
return utils.PrintJSON(map[string]interface{}{
"pool_txid": poolTxID,
})
}
func coinSelect(vtxos []vtxo, amount uint64, sortByExpirationTime bool) ([]vtxo, uint64, error) {
selected := make([]vtxo, 0)
notSelected := make([]vtxo, 0)
selectedAmount := uint64(0)
if sortByExpirationTime {
// sort vtxos by expiration (older first)
sort.SliceStable(vtxos, func(i, j int) bool {
if vtxos[i].expireAt == nil || vtxos[j].expireAt == nil {
return false
}
return vtxos[i].expireAt.Before(*vtxos[j].expireAt)
})
}
for _, vtxo := range vtxos {
if selectedAmount >= amount {
notSelected = append(notSelected, vtxo)
break
}
selected = append(selected, vtxo)
selectedAmount += vtxo.amount
}
if selectedAmount < amount {
return nil, 0, fmt.Errorf("not enough funds to cover amount%d", amount)
}
change := selectedAmount - amount
if change < dust {
if len(notSelected) > 0 {
selected = append(selected, notSelected[0])
change += notSelected[0].amount
}
}
return selected, change, nil
}

View File

@@ -0,0 +1,185 @@
package covenantless
import (
"bytes"
"encoding/hex"
"fmt"
"strings"
"github.com/ark-network/ark-cli/utils"
"github.com/ark-network/ark/common/bitcointree"
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/urfave/cli/v2"
)
func signPsbt(
ctx *cli.Context, ptx *psbt.Packet, explorer utils.Explorer, prvKey *secp256k1.PrivateKey,
) error {
updater, err := psbt.NewUpdater(ptx)
if err != nil {
return err
}
for i, input := range updater.Upsbt.UnsignedTx.TxIn {
if updater.Upsbt.Inputs[i].WitnessUtxo != nil {
continue
}
prevoutTxHex, err := explorer.GetTxHex(input.PreviousOutPoint.Hash.String())
if err != nil {
return err
}
var prevoutTx wire.MsgTx
if err := prevoutTx.Deserialize(hex.NewDecoder(strings.NewReader(prevoutTxHex))); err != nil {
return err
}
utxo := prevoutTx.TxOut[input.PreviousOutPoint.Index]
if utxo == nil {
return fmt.Errorf("witness utxo not found")
}
if err := updater.AddInWitnessUtxo(utxo, i); err != nil {
return err
}
sighashType := txscript.SigHashAll
if utxo.PkScript[0] == txscript.OP_1 {
sighashType = txscript.SigHashDefault
}
if err := updater.AddInSighashType(sighashType, i); err != nil {
return err
}
}
_, onchainAddr, _, err := getAddress(ctx)
if err != nil {
return err
}
onchainWalletScript, err := txscript.PayToAddrScript(onchainAddr)
if err != nil {
return err
}
prevouts := make(map[wire.OutPoint]*wire.TxOut)
for i, input := range updater.Upsbt.Inputs {
outpoint := updater.Upsbt.UnsignedTx.TxIn[i].PreviousOutPoint
prevouts[outpoint] = input.WitnessUtxo
}
prevoutFetcher := txscript.NewMultiPrevOutFetcher(
prevouts,
)
txsighashes := txscript.NewTxSigHashes(updater.Upsbt.UnsignedTx, prevoutFetcher)
for i, input := range ptx.Inputs {
if bytes.Equal(input.WitnessUtxo.PkScript, onchainWalletScript) {
if err := updater.AddInSighashType(txscript.SigHashAll, i); err != nil {
return err
}
preimage, err := txscript.CalcWitnessSigHash(
input.WitnessUtxo.PkScript,
txsighashes,
txscript.SigHashAll,
updater.Upsbt.UnsignedTx,
i,
int64(input.WitnessUtxo.Value),
)
if err != nil {
return err
}
sig := ecdsa.Sign(
prvKey,
preimage,
)
signatureWithSighashType := append(sig.Serialize(), byte(txscript.SigHashAll))
updater.Upsbt.Inputs[i].PartialSigs = []*psbt.PartialSig{
{
PubKey: prvKey.PubKey().SerializeCompressed(),
Signature: signatureWithSighashType,
},
}
continue
}
if len(input.TaprootLeafScript) > 0 {
pubkey := prvKey.PubKey()
for _, leaf := range input.TaprootLeafScript {
closure, err := bitcointree.DecodeClosure(leaf.Script)
if err != nil {
return err
}
sign := false
switch c := closure.(type) {
case *bitcointree.CSVSigClosure:
sign = bytes.Equal(c.Pubkey.SerializeCompressed()[1:], pubkey.SerializeCompressed()[1:])
case *bitcointree.ForfeitClosure:
sign = bytes.Equal(c.Pubkey.SerializeCompressed()[1:], pubkey.SerializeCompressed()[1:])
}
if sign {
if err := updater.AddInSighashType(txscript.SigHashDefault, i); err != nil {
return err
}
hash := txscript.NewTapLeaf(leaf.LeafVersion, leaf.Script).TapHash()
preimage, err := txscript.CalcTapscriptSignaturehash(
txsighashes,
txscript.SigHashDefault,
ptx.UnsignedTx,
i,
prevoutFetcher,
txscript.NewBaseTapLeaf(leaf.Script),
)
if err != nil {
return err
}
sig, err := schnorr.Sign(
prvKey,
preimage,
)
if err != nil {
return err
}
if !sig.Verify(preimage, prvKey.PubKey()) {
return fmt.Errorf("signature verification failed")
}
updater.Upsbt.Inputs[i].TaprootScriptSpendSig = []*psbt.TaprootScriptSpendSig{
{
XOnlyPubKey: schnorr.SerializePubKey(prvKey.PubKey()),
LeafHash: hash.CloneBytes(),
Signature: sig.Serialize(),
SigHash: txscript.SigHashDefault,
},
}
}
}
}
}
return nil
}

View File

@@ -0,0 +1,45 @@
package covenantless
import (
"github.com/ark-network/ark/common/bitcointree"
"github.com/btcsuite/btcd/txscript"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
)
func computeVtxoTaprootScript(
userPubkey, aspPubkey *secp256k1.PublicKey, exitDelay uint,
) (*secp256k1.PublicKey, *txscript.TapscriptProof, error) {
redeemClosure := &bitcointree.CSVSigClosure{
Pubkey: userPubkey,
Seconds: exitDelay,
}
forfeitClosure := &bitcointree.ForfeitClosure{
Pubkey: userPubkey,
AspPubkey: aspPubkey,
}
redeemLeaf, err := redeemClosure.Leaf()
if err != nil {
return nil, nil, err
}
forfeitLeaf, err := forfeitClosure.Leaf()
if err != nil {
return nil, nil, err
}
vtxoTaprootTree := txscript.AssembleTaprootScriptTree(
*redeemLeaf, *forfeitLeaf,
)
root := vtxoTaprootTree.RootNode.TapHash()
unspendableKey := bitcointree.UnspendableKey()
vtxoTaprootKey := txscript.ComputeTaprootOutputKey(unspendableKey, root[:])
redeemLeafHash := redeemLeaf.TapHash()
proofIndex := vtxoTaprootTree.LeafProofIndex[redeemLeafHash]
proof := vtxoTaprootTree.LeafMerkleProofs[proofIndex]
return vtxoTaprootKey, &proof, nil
}

View File

@@ -1,25 +0,0 @@
package main
import (
"encoding/hex"
"github.com/urfave/cli/v2"
)
var dumpCommand = cli.Command{
Name: "dump-privkey",
Usage: "Dumps private key of the Ark wallet",
Action: dumpAction,
Flags: []cli.Flag{&passwordFlag},
}
func dumpAction(ctx *cli.Context) error {
privateKey, err := privateKeyFromPassword(ctx)
if err != nil {
return err
}
return printJSON(map[string]interface{}{
"private_key": hex.EncodeToString(privateKey.Serialize()),
})
}

93
client/flags/flags.go Normal file
View File

@@ -0,0 +1,93 @@
package flags
import (
"github.com/ark-network/ark/common"
"github.com/urfave/cli/v2"
)
const DATADIR_ENVVAR = "ARK_WALLET_DATADIR"
var (
DatadirFlag = &cli.StringFlag{
Name: "datadir",
Usage: "Specify the data directory",
Required: false,
Value: common.AppDataDir("ark-cli", false),
EnvVars: []string{DATADIR_ENVVAR},
}
PasswordFlag = cli.StringFlag{
Name: "password",
Usage: "password to unlock the wallet",
Required: false,
Hidden: true,
}
AmountOnboardFlag = cli.Uint64Flag{
Name: "amount",
Usage: "amount to onboard in sats",
}
TrustedOnboardFlag = cli.BoolFlag{
Name: "trusted",
Usage: "trusted onboard",
}
ExpiryDetailsFlag = cli.BoolFlag{
Name: "compute-expiry-details",
Usage: "compute client-side the VTXOs expiry time",
Value: false,
Required: false,
}
PrivateKeyFlag = cli.StringFlag{
Name: "prvkey",
Usage: "optional, private key to encrypt",
}
NetworkFlag = cli.StringFlag{
Name: "network",
Usage: "network to use (liquid, testnet, regtest)",
Value: "liquid",
}
UrlFlag = cli.StringFlag{
Name: "ark-url",
Usage: "the url of the ASP to connect to",
Required: true,
}
ExplorerFlag = cli.StringFlag{
Name: "explorer",
Usage: "the url of the explorer to use",
}
ReceiversFlag = cli.StringFlag{
Name: "receivers",
Usage: "receivers of the send transaction, JSON encoded: '[{\"to\": \"<...>\", \"amount\": <...>}, ...]'",
}
ToFlag = cli.StringFlag{
Name: "to",
Usage: "address of the recipient",
}
AmountFlag = cli.Uint64Flag{
Name: "amount",
Usage: "amount to send in sats",
}
EnableExpiryCoinselectFlag = cli.BoolFlag{
Name: "enable-expiry-coinselect",
Usage: "select vtxos that are about to expire first",
Value: false,
}
AddressFlag = cli.StringFlag{
Name: "address",
Usage: "main chain address receiving the redeeemed VTXO",
Value: "",
Required: false,
}
AmountToRedeemFlag = cli.Uint64Flag{
Name: "amount",
Usage: "amount to redeem",
Value: 0,
Required: false,
}
ForceFlag = cli.BoolFlag{
Name: "force",
Usage: "force redemption without collaborate with the Ark service provider",
Value: false,
Required: false,
}
)

View File

@@ -11,6 +11,7 @@ require (
github.com/ark-network/ark/common v0.0.0
github.com/btcsuite/btcd v0.24.2
github.com/btcsuite/btcd/btcec/v2 v2.3.4
github.com/btcsuite/btcd/btcutil/psbt v1.1.9
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/urfave/cli/v2 v2.27.2
@@ -19,24 +20,23 @@ require (
)
require (
github.com/btcsuite/btcd/btcutil/psbt v1.1.9 // indirect
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
github.com/vulpemventures/fastsha256 v0.0.0-20160815193821-637e65642941 // indirect
)
require (
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/vulpemventures/go-elements v0.5.3
github.com/vulpemventures/go-elements v0.5.4
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.34.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
)

View File

@@ -88,8 +88,8 @@ github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI=
github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM=
github.com/vulpemventures/fastsha256 v0.0.0-20160815193821-637e65642941 h1:CTcw80hz/Sw8hqlKX5ZYvBUF5gAHSHwdjXxRf/cjDcI=
github.com/vulpemventures/fastsha256 v0.0.0-20160815193821-637e65642941/go.mod h1:GXBJykxW2kUcktGdsgyay7uwwWvkljASfljNcT0mbh8=
github.com/vulpemventures/go-elements v0.5.3 h1:zaC/ynHFwCAzFSOMfzb6BcbD6FXASppSiGMycc95WVA=
github.com/vulpemventures/go-elements v0.5.3/go.mod h1:aBGuWXHaiAIUIcwqCdtEh2iQ3kJjKwHU9ywvhlcRSeU=
github.com/vulpemventures/go-elements v0.5.4 h1:l94xoa9aYPPWiOB7Pmi08rKYvdk/n/sQIbLkQfEAASc=
github.com/vulpemventures/go-elements v0.5.4/go.mod h1:Tvhb+rZWv3lxoI5CdK03J3V+e2QVr/7UAnCYILxFSq4=
github.com/vulpemventures/go-secp256k1-zkp v1.1.6 h1:BmsrmXRLUibwa75Qkk8yELjpzCzlAjYFGLiLiOdq7Xo=
github.com/vulpemventures/go-secp256k1-zkp v1.1.6/go.mod h1:zo7CpgkuPgoe7fAV+inyxsI9IhGmcoFgyD8nqZaPSOM=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
@@ -128,10 +128,10 @@ golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d h1:Aqf0fiIdUQEj0Gn9mKFFXoQfTTEaNopWpfVyYADxiSg=
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Od4k8V1LQSizPRUK4OzZ7TBE/20k+jPczUDAEyvn69Y=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d h1:k3zyW3BYYR30e8v3x0bTDdE9vpYFjZHK+HcyqkrppWk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
@@ -140,8 +140,8 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=

12
client/interfaces/cli.go Normal file
View File

@@ -0,0 +1,12 @@
package interfaces
import "github.com/urfave/cli/v2"
type CLI interface {
Balance(ctx *cli.Context) error
Init(ctx *cli.Context) error
Receive(ctx *cli.Context) error
Redeem(ctx *cli.Context) error
Send(ctx *cli.Context) error
Onboard(ctx *cli.Context) error
}

View File

@@ -1,63 +1,131 @@
package main
import (
"encoding/json"
"encoding/hex"
"fmt"
"os"
"os/user"
"path/filepath"
"strings"
"github.com/ark-network/ark-cli/covenant"
"github.com/ark-network/ark-cli/covenantless"
"github.com/ark-network/ark-cli/flags"
"github.com/ark-network/ark-cli/interfaces"
"github.com/ark-network/ark-cli/utils"
"github.com/ark-network/ark/common"
"github.com/urfave/cli/v2"
"github.com/vulpemventures/go-elements/network"
)
const (
DATADIR_ENVVAR = "ARK_WALLET_DATADIR"
STATE_FILE = "state.json"
defaultNetwork = "liquid"
ASP_URL = "asp_url"
ASP_PUBKEY = "asp_public_key"
ROUND_LIFETIME = "round_lifetime"
UNILATERAL_EXIT_DELAY = "unilateral_exit_delay"
ENCRYPTED_PRVKEY = "encrypted_private_key"
PASSWORD_HASH = "password_hash"
PUBKEY = "public_key"
NETWORK = "network"
EXPLORER = "explorer"
)
var version = "alpha"
var (
version = "alpha"
defaultDatadir = common.AppDataDir("ark-cli", false)
explorerUrl = map[string]string{
network.Liquid.Name: "https://blockstream.info/liquid/api",
network.Testnet.Name: "https://blockstream.info/liquidtestnet/api",
network.Regtest.Name: "http://localhost:3001",
balanceCommand = cli.Command{
Name: "balance",
Usage: "Shows the onchain and offchain balance of the Ark wallet",
Action: func(ctx *cli.Context) error {
cli, err := getCLIFromState(ctx)
if err != nil {
return err
}
return cli.Balance(ctx)
},
Flags: []cli.Flag{&flags.ExpiryDetailsFlag},
}
initialState = map[string]string{
ASP_URL: "",
ASP_PUBKEY: "",
ROUND_LIFETIME: "",
UNILATERAL_EXIT_DELAY: "",
ENCRYPTED_PRVKEY: "",
PASSWORD_HASH: "",
PUBKEY: "",
NETWORK: defaultNetwork,
configCommand = cli.Command{
Name: "config",
Usage: "Shows configuration of the Ark wallet",
Action: func(ctx *cli.Context) error {
state, err := utils.GetState(ctx)
if err != nil {
return err
}
datadirFlag = &cli.StringFlag{
Name: "datadir",
Usage: "Specify the data directory",
Required: false,
Value: defaultDatadir,
EnvVars: []string{DATADIR_ENVVAR},
return utils.PrintJSON(state)
},
}
dumpCommand = cli.Command{
Name: "dump-privkey",
Usage: "Dumps private key of the Ark wallet",
Action: func(ctx *cli.Context) error {
privKey, err := utils.PrivateKeyFromPassword(ctx)
if err != nil {
return err
}
return utils.PrintJSON(map[string]interface{}{
"private_key": hex.EncodeToString(privKey.Serialize()),
})
},
Flags: []cli.Flag{&flags.PasswordFlag},
}
initCommand = cli.Command{
Name: "init",
Usage: "Initialize your Ark wallet with an encryption password, and connect it to an ASP",
Action: func(ctx *cli.Context) error {
cli, err := getCLIFromFlags(ctx)
if err != nil {
return err
}
return cli.Init(ctx)
},
Flags: []cli.Flag{&flags.PasswordFlag, &flags.PrivateKeyFlag, &flags.NetworkFlag, &flags.UrlFlag, &flags.ExplorerFlag},
}
onboardCommand = cli.Command{
Name: "onboard",
Usage: "Onboard the Ark by lifting your funds",
Action: func(ctx *cli.Context) error {
cli, err := getCLIFromState(ctx)
if err != nil {
return err
}
return cli.Onboard(ctx)
},
Flags: []cli.Flag{&flags.AmountOnboardFlag, &flags.TrustedOnboardFlag, &flags.PasswordFlag},
}
sendCommand = cli.Command{
Name: "send",
Usage: "Send your onchain or offchain funds to one or many receivers",
Action: func(ctx *cli.Context) error {
cli, err := getCLIFromState(ctx)
if err != nil {
return err
}
return cli.Send(ctx)
},
Flags: []cli.Flag{&flags.ReceiversFlag, &flags.ToFlag, &flags.AmountFlag, &flags.PasswordFlag, &flags.EnableExpiryCoinselectFlag},
}
receiveCommand = cli.Command{
Name: "receive",
Usage: "Shows both onchain and offchain addresses",
Action: func(ctx *cli.Context) error {
cli, err := getCLIFromState(ctx)
if err != nil {
return err
}
return cli.Receive(ctx)
},
}
redeemCommand = cli.Command{
Name: "redeem",
Usage: "Redeem your offchain funds, either collaboratively or unilaterally",
Flags: []cli.Flag{&flags.AddressFlag, &flags.AmountToRedeemFlag, &flags.ForceFlag, &flags.PasswordFlag, &flags.EnableExpiryCoinselectFlag},
Action: func(ctx *cli.Context) error {
cli, err := getCLIFromState(ctx)
if err != nil {
return err
}
return cli.Redeem(ctx)
},
}
)
@@ -79,7 +147,7 @@ func main() {
&onboardCommand,
)
app.Flags = []cli.Flag{
datadirFlag,
flags.DatadirFlag,
}
app.Before = func(ctx *cli.Context) error {
@@ -102,6 +170,32 @@ func main() {
}
}
func getCLIFromState(ctx *cli.Context) (interfaces.CLI, error) {
state, err := utils.GetState(ctx)
if err != nil {
return nil, err
}
networkName := state[utils.NETWORK]
return getCLI(networkName)
}
func getCLIFromFlags(ctx *cli.Context) (interfaces.CLI, error) {
networkName := strings.ToLower(ctx.String("network"))
return getCLI(networkName)
}
func getCLI(networkName string) (interfaces.CLI, error) {
switch networkName {
case common.Liquid.Name, common.LiquidTestNet.Name, common.LiquidRegTest.Name:
return covenant.New(), nil
case common.Bitcoin.Name, common.BitcoinTestNet.Name, common.BitcoinRegTest.Name:
return covenantless.New(), nil
default:
return nil, fmt.Errorf("unknown network (%s)", networkName)
}
}
// cleanAndExpandPath expands environment variables and leading ~ in the
// passed path, cleans the result, and returns it.
// This function is taken from https://github.com/btcsuite/btcd
@@ -127,67 +221,3 @@ func cleanAndExpandPath(path string) string {
// but the variables can still be expanded via POSIX-style $VARIABLE.
return filepath.Clean(os.ExpandEnv(path))
}
func getState(ctx *cli.Context) (map[string]string, error) {
datadir := ctx.String("datadir")
stateFilePath := filepath.Join(datadir, STATE_FILE)
file, err := os.ReadFile(stateFilePath)
if err != nil {
if !os.IsNotExist(err) {
return nil, err
}
if err := setInitialState(stateFilePath); err != nil {
return nil, err
}
return initialState, nil
}
data := map[string]string{}
if err := json.Unmarshal(file, &data); err != nil {
return nil, err
}
return data, nil
}
func setInitialState(stateFilePath string) error {
jsonString, err := json.Marshal(initialState)
if err != nil {
return err
}
return os.WriteFile(stateFilePath, jsonString, 0755)
}
func setState(ctx *cli.Context, data map[string]string) error {
currentData, err := getState(ctx)
if err != nil {
return err
}
mergedData := merge(currentData, data)
jsonString, err := json.Marshal(mergedData)
if err != nil {
return err
}
datadir := ctx.String("datadir")
statePath := filepath.Join(datadir, STATE_FILE)
err = os.WriteFile(statePath, jsonString, 0755)
if err != nil {
return fmt.Errorf("writing to file: %w", err)
}
return nil
}
func merge(maps ...map[string]string) map[string]string {
merge := make(map[string]string, 0)
for _, m := range maps {
for k, v := range m {
merge[k] = v
}
}
return merge
}

View File

@@ -1,23 +0,0 @@
package main
import (
"github.com/urfave/cli/v2"
)
var receiveCommand = cli.Command{
Name: "receive",
Usage: "Shows both onchain and offchain addresses",
Action: receiveAction,
}
func receiveAction(ctx *cli.Context) error {
offchainAddr, onchainAddr, _, err := getAddress(ctx)
if err != nil {
return err
}
return printJSON(map[string]interface{}{
"offchain_address": offchainAddr,
"onchain_address": onchainAddr,
})
}

View File

@@ -1,366 +0,0 @@
package main
import (
"bytes"
"encoding/json"
"fmt"
"math"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common"
"github.com/urfave/cli/v2"
"github.com/vulpemventures/go-elements/address"
"github.com/vulpemventures/go-elements/psetv2"
)
type receiver struct {
To string `json:"to"`
Amount uint64 `json:"amount"`
}
func (r *receiver) isOnchain() bool {
_, err := address.ToOutputScript(r.To)
return err == nil
}
var (
receiversFlag = cli.StringFlag{
Name: "receivers",
Usage: "receivers of the send transaction, JSON encoded: '[{\"to\": \"<...>\", \"amount\": <...>}, ...]'",
}
toFlag = cli.StringFlag{
Name: "to",
Usage: "address of the recipient",
}
amountFlag = cli.Uint64Flag{
Name: "amount",
Usage: "amount to send in sats",
}
enableExpiryCoinselectFlag = cli.BoolFlag{
Name: "enable-expiry-coinselect",
Usage: "select vtxos that are about to expire first",
Value: false,
}
)
var sendCommand = cli.Command{
Name: "send",
Usage: "Send your onchain or offchain funds to one or many receivers",
Action: sendAction,
Flags: []cli.Flag{&receiversFlag, &toFlag, &amountFlag, &passwordFlag, &enableExpiryCoinselectFlag},
}
func sendAction(ctx *cli.Context) error {
if !ctx.IsSet("receivers") && !ctx.IsSet("to") && !ctx.IsSet("amount") {
return fmt.Errorf("missing destination, either use --to and --amount to send or --receivers to send to many")
}
receivers := ctx.String("receivers")
to := ctx.String("to")
amount := ctx.Uint64("amount")
var receiversJSON []receiver
if len(receivers) > 0 {
if err := json.Unmarshal([]byte(receivers), &receiversJSON); err != nil {
return fmt.Errorf("invalid receivers: %s", err)
}
} else {
receiversJSON = []receiver{
{
To: to,
Amount: amount,
},
}
}
if len(receiversJSON) <= 0 {
return fmt.Errorf("no receivers specified")
}
onchainReceivers := make([]receiver, 0)
offchainReceivers := make([]receiver, 0)
for _, receiver := range receiversJSON {
if receiver.isOnchain() {
onchainReceivers = append(onchainReceivers, receiver)
} else {
offchainReceivers = append(offchainReceivers, receiver)
}
}
explorer := NewExplorer(ctx)
if len(onchainReceivers) > 0 {
pset, err := sendOnchain(ctx, onchainReceivers)
if err != nil {
return err
}
txid, err := explorer.Broadcast(pset)
if err != nil {
return err
}
return printJSON(map[string]interface{}{
"txid": txid,
})
}
if len(offchainReceivers) > 0 {
if err := sendOffchain(ctx, offchainReceivers); err != nil {
return err
}
}
return nil
}
func sendOffchain(ctx *cli.Context, receivers []receiver) error {
withExpiryCoinselect := ctx.Bool("enable-expiry-coinselect")
offchainAddr, _, _, err := getAddress(ctx)
if err != nil {
return err
}
_, _, aspPubKey, err := common.DecodeAddress(offchainAddr)
if err != nil {
return err
}
receiversOutput := make([]*arkv1.Output, 0)
sumOfReceivers := uint64(0)
for _, receiver := range receivers {
_, _, aspKey, err := common.DecodeAddress(receiver.To)
if err != nil {
return fmt.Errorf("invalid receiver address: %s", err)
}
if !bytes.Equal(
aspPubKey.SerializeCompressed(), aspKey.SerializeCompressed(),
) {
return fmt.Errorf("invalid receiver address '%s': must be associated with the connected service provider", receiver.To)
}
if receiver.Amount < DUST {
return fmt.Errorf("invalid amount (%d), must be greater than dust %d", receiver.Amount, DUST)
}
receiversOutput = append(receiversOutput, &arkv1.Output{
Address: receiver.To,
Amount: uint64(receiver.Amount),
})
sumOfReceivers += receiver.Amount
}
client, close, err := getClientFromState(ctx)
if err != nil {
return err
}
defer close()
explorer := NewExplorer(ctx)
vtxos, err := getVtxos(ctx, explorer, client, offchainAddr, withExpiryCoinselect)
if err != nil {
return err
}
selectedCoins, changeAmount, err := coinSelect(vtxos, sumOfReceivers, withExpiryCoinselect)
if err != nil {
return err
}
if changeAmount > 0 {
changeReceiver := &arkv1.Output{
Address: offchainAddr,
Amount: changeAmount,
}
receiversOutput = append(receiversOutput, changeReceiver)
}
inputs := make([]*arkv1.Input, 0, len(selectedCoins))
for _, coin := range selectedCoins {
inputs = append(inputs, &arkv1.Input{
Txid: coin.txid,
Vout: coin.vout,
})
}
secKey, err := privateKeyFromPassword(ctx)
if err != nil {
return err
}
registerResponse, err := client.RegisterPayment(
ctx.Context, &arkv1.RegisterPaymentRequest{Inputs: inputs},
)
if err != nil {
return err
}
_, err = client.ClaimPayment(ctx.Context, &arkv1.ClaimPaymentRequest{
Id: registerResponse.GetId(),
Outputs: receiversOutput,
})
if err != nil {
return err
}
poolTxID, err := handleRoundStream(
ctx, client, registerResponse.GetId(),
selectedCoins, secKey, receiversOutput,
)
if err != nil {
return err
}
return printJSON(map[string]interface{}{
"pool_txid": poolTxID,
})
}
func sendOnchain(ctx *cli.Context, receivers []receiver) (string, error) {
pset, err := psetv2.New(nil, nil, nil)
if err != nil {
return "", err
}
updater, err := psetv2.NewUpdater(pset)
if err != nil {
return "", err
}
_, net := getNetwork(ctx)
targetAmount := uint64(0)
for _, receiver := range receivers {
targetAmount += receiver.Amount
if receiver.Amount < DUST {
return "", fmt.Errorf("invalid amount (%d), must be greater than dust %d", receiver.Amount, DUST)
}
script, err := address.ToOutputScript(receiver.To)
if err != nil {
return "", err
}
if err := updater.AddOutputs([]psetv2.OutputArgs{
{
Asset: net.AssetID,
Amount: receiver.Amount,
Script: script,
},
}); err != nil {
return "", err
}
}
explorer := NewExplorer(ctx)
utxos, delayedUtxos, change, err := coinSelectOnchain(
ctx, explorer, targetAmount, nil,
)
if err != nil {
return "", err
}
if err := addInputs(ctx, updater, utxos, delayedUtxos, net); err != nil {
return "", err
}
if change > 0 {
_, changeAddr, _, err := getAddress(ctx)
if err != nil {
return "", err
}
changeScript, err := address.ToOutputScript(changeAddr)
if err != nil {
return "", err
}
if err := updater.AddOutputs([]psetv2.OutputArgs{
{
Asset: net.AssetID,
Amount: change,
Script: changeScript,
},
}); err != nil {
return "", err
}
}
utx, err := pset.UnsignedTx()
if err != nil {
return "", err
}
vBytes := utx.VirtualSize()
feeAmount := uint64(math.Ceil(float64(vBytes) * 0.5))
if change > feeAmount {
updater.Pset.Outputs[len(updater.Pset.Outputs)-1].Value = change - feeAmount
} else if change == feeAmount {
updater.Pset.Outputs = updater.Pset.Outputs[:len(updater.Pset.Outputs)-1]
} else { // change < feeAmount
if change > 0 {
updater.Pset.Outputs = updater.Pset.Outputs[:len(updater.Pset.Outputs)-1]
}
// reselect the difference
selected, delayedSelected, newChange, err := coinSelectOnchain(
ctx, explorer, feeAmount-change, append(utxos, delayedUtxos...),
)
if err != nil {
return "", err
}
if err := addInputs(ctx, updater, selected, delayedSelected, net); err != nil {
return "", err
}
if newChange > 0 {
_, changeAddr, _, err := getAddress(ctx)
if err != nil {
return "", err
}
changeScript, err := address.ToOutputScript(changeAddr)
if err != nil {
return "", err
}
if err := updater.AddOutputs([]psetv2.OutputArgs{
{
Asset: net.AssetID,
Amount: newChange,
Script: changeScript,
},
}); err != nil {
return "", err
}
}
}
if err := updater.AddOutputs([]psetv2.OutputArgs{
{
Asset: net.AssetID,
Amount: feeAmount,
},
}); err != nil {
return "", err
}
prvKey, err := privateKeyFromPassword(ctx)
if err != nil {
return "", err
}
if err := signPset(ctx, updater.Pset, explorer, prvKey); err != nil {
return "", err
}
if err := psetv2.FinalizeAll(updater.Pset); err != nil {
return "", err
}
return updater.Pset.ToBase64()
}

View File

@@ -1,4 +1,4 @@
package main
package utils
import (
"crypto/aes"
@@ -12,11 +12,11 @@ import (
type cypher struct{}
func newAES128Cypher() *cypher {
func NewAES128Cypher() *cypher {
return &cypher{}
}
func (c *cypher) encrypt(privateKey, password []byte) ([]byte, error) {
func (c *cypher) Encrypt(privateKey, password []byte) ([]byte, error) {
// Due to https://github.com/golang/go/issues/7168.
// This call makes sure that memory is freed in case the GC doesn't do that
// right after the encryption/decryption.

View File

@@ -1,24 +1,28 @@
package main
package utils
import (
"bytes"
"encoding/hex"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"time"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/wire"
"github.com/urfave/cli/v2"
"github.com/vulpemventures/go-elements/psetv2"
"github.com/vulpemventures/go-elements/transaction"
)
type utxo struct {
type Utxo struct {
Txid string `json:"txid"`
Vout uint32 `json:"vout"`
Amount uint64 `json:"value"`
Asset string `json:"asset"`
Asset string `json:"asset,omitempty"` // optional
Status struct {
Confirmed bool `json:"confirmed"`
Blocktime int64 `json:"block_time"`
@@ -28,11 +32,13 @@ type utxo struct {
type Explorer interface {
GetTxHex(txid string) (string, error)
Broadcast(txHex string) (string, error)
GetUtxos(addr string) ([]utxo, error)
GetUtxos(addr string) ([]Utxo, error)
GetBalance(addr, asset string) (uint64, error)
GetRedeemedVtxosBalance(
addr string, unilateralExitDelay int64,
) (uint64, map[int64]uint64, error)
GetTxBlocktime(txid string) (confirmed bool, blocktime int64, err error)
GetFeeRate() (float64, error)
}
type explorer struct {
@@ -52,6 +58,37 @@ func NewExplorer(ctx *cli.Context) Explorer {
}
}
func (e *explorer) GetFeeRate() (float64, error) {
endpoint, err := url.JoinPath(e.baseUrl, "fee-estimates")
if err != nil {
return 0, err
}
resp, err := http.Get(endpoint)
if err != nil {
return 0, err
}
defer resp.Body.Close()
var response map[string]float64
if err := json.NewDecoder(resp.Body).Decode(&response); err != nil {
return 0, err
}
if resp.StatusCode != http.StatusOK {
return 0, fmt.Errorf("error getting fee rate: %s", resp.Status)
}
if len(response) == 0 {
fmt.Println("empty fee-estimates response, default to 2 sat/vbyte")
return 2, nil
}
fmt.Println("fee rate", response["1"])
return response["1"], nil
}
func (e *explorer) GetTxHex(txid string) (string, error) {
if hex, ok := e.cache[txid]; ok {
return hex, nil
@@ -68,20 +105,16 @@ func (e *explorer) GetTxHex(txid string) (string, error) {
}
func (e *explorer) Broadcast(txStr string) (string, error) {
tx, err := transaction.NewTxFromHex(txStr)
clone := strings.Clone(txStr)
txStr, txid, err := parseLiquidTx(txStr)
if err != nil {
pset, err := psetv2.NewPsetFromBase64(txStr)
txStr, txid, err = parseBitcoinTx(clone)
if err != nil {
fmt.Println("error parsing tx hex")
return "", err
}
}
tx, err = psetv2.Extract(pset)
if err != nil {
return "", err
}
txStr, _ = tx.ToHex()
}
txid := tx.TxHash().String()
e.cache[txid] = txStr
txid, err = e.broadcast(txStr)
@@ -98,8 +131,13 @@ func (e *explorer) Broadcast(txStr string) (string, error) {
return txid, nil
}
func (e *explorer) GetUtxos(addr string) ([]utxo, error) {
resp, err := http.Get(fmt.Sprintf("%s/address/%s/utxo", e.baseUrl, addr))
func (e *explorer) GetUtxos(addr string) ([]Utxo, error) {
endpoint, err := url.JoinPath(e.baseUrl, "address", addr, "utxo")
if err != nil {
return nil, err
}
resp, err := http.Get(endpoint)
if err != nil {
return nil, err
}
@@ -112,7 +150,7 @@ func (e *explorer) GetUtxos(addr string) ([]utxo, error) {
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(string(body))
}
payload := []utxo{}
payload := []Utxo{}
if err := json.Unmarshal(body, &payload); err != nil {
return nil, err
}
@@ -128,9 +166,11 @@ func (e *explorer) GetBalance(addr, asset string) (uint64, error) {
balance := uint64(0)
for _, p := range payload {
if len(asset) > 0 {
if p.Asset != asset {
continue
}
}
balance += p.Amount
}
return balance, nil
@@ -168,8 +208,51 @@ func (e *explorer) GetRedeemedVtxosBalance(
return
}
func (e *explorer) GetTxBlocktime(txid string) (confirmed bool, blocktime int64, err error) {
endpoint, err := url.JoinPath(e.baseUrl, "tx", txid)
if err != nil {
return false, 0, err
}
resp, err := http.Get(endpoint)
if err != nil {
return false, 0, err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return false, 0, err
}
if resp.StatusCode != http.StatusOK {
return false, 0, fmt.Errorf(string(body))
}
var tx struct {
Status struct {
Confirmed bool `json:"confirmed"`
Blocktime int64 `json:"block_time"`
} `json:"status"`
}
if err := json.Unmarshal(body, &tx); err != nil {
return false, 0, err
}
if !tx.Status.Confirmed {
return false, -1, nil
}
return true, tx.Status.Blocktime, nil
}
func (e *explorer) getTxHex(txid string) (string, error) {
resp, err := http.Get(fmt.Sprintf("%s/tx/%s/hex", e.baseUrl, txid))
endpoint, err := url.JoinPath(e.baseUrl, "tx", txid, "hex")
if err != nil {
return "", err
}
resp, err := http.Get(endpoint)
if err != nil {
return "", err
}
@@ -191,7 +274,12 @@ func (e *explorer) getTxHex(txid string) (string, error) {
func (e *explorer) broadcast(txHex string) (string, error) {
body := bytes.NewBuffer([]byte(txHex))
resp, err := http.Post(fmt.Sprintf("%s/tx", e.baseUrl), "text/plain", body)
endpoint, err := url.JoinPath(e.baseUrl, "tx")
if err != nil {
return "", err
}
resp, err := http.Post(endpoint, "text/plain", body)
if err != nil {
return "", err
}
@@ -207,3 +295,65 @@ func (e *explorer) broadcast(txHex string) (string, error) {
return string(bodyResponse), nil
}
func parseLiquidTx(txStr string) (string, string, error) {
tx, err := transaction.NewTxFromHex(txStr)
if err != nil {
pset, err := psetv2.NewPsetFromBase64(txStr)
if err != nil {
return "", "", err
}
tx, err = psetv2.Extract(pset)
if err != nil {
return "", "", err
}
txhex, err := tx.ToHex()
if err != nil {
return "", "", err
}
txid := tx.TxHash().String()
return txhex, txid, nil
}
txhex, err := tx.ToHex()
if err != nil {
return "", "", err
}
txid := tx.TxHash().String()
return txhex, txid, nil
}
func parseBitcoinTx(txStr string) (string, string, error) {
var tx wire.MsgTx
if err := tx.Deserialize(hex.NewDecoder(strings.NewReader(txStr))); err != nil {
ptx, err := psbt.NewFromRawBytes(strings.NewReader(txStr), true)
if err != nil {
return "", "", err
}
txFromPartial, err := psbt.Extract(ptx)
if err != nil {
return "", "", err
}
tx = *txFromPartial
}
var txBuf bytes.Buffer
if err := tx.Serialize(&txBuf); err != nil {
return "", "", err
}
txhex := hex.EncodeToString(txBuf.Bytes())
txid := tx.TxHash().String()
return txhex, txid, nil
}

16
client/utils/json.go Normal file
View File

@@ -0,0 +1,16 @@
package utils
import (
"encoding/json"
"fmt"
)
func PrintJSON(resp interface{}) error {
jsonBytes, err := json.MarshalIndent(resp, "", "\t")
if err != nil {
return err
}
fmt.Println(string(jsonBytes))
return nil
}

65
client/utils/password.go Normal file
View File

@@ -0,0 +1,65 @@
package utils
import (
"bytes"
"crypto/sha256"
"encoding/hex"
"fmt"
"syscall"
"github.com/urfave/cli/v2"
"golang.org/x/term"
)
func ReadPassword(ctx *cli.Context, verify bool) ([]byte, error) {
password := []byte(ctx.String("password"))
if len(password) == 0 {
fmt.Print("unlock your wallet with password: ")
var err error
password, err = term.ReadPassword(int(syscall.Stdin))
fmt.Println() // new line
if err != nil {
return nil, err
}
}
if verify {
if err := verifyPassword(ctx, password); err != nil {
return nil, err
}
}
return password, nil
}
func HashPassword(password []byte) []byte {
hash := sha256.Sum256(password)
return hash[:]
}
func verifyPassword(ctx *cli.Context, password []byte) error {
state, err := GetState(ctx)
if err != nil {
return err
}
passwordHashString := state[PASSWORD_HASH]
if len(passwordHashString) <= 0 {
return fmt.Errorf("missing password hash")
}
passwordHash, err := hex.DecodeString(passwordHashString)
if err != nil {
return err
}
currentPassHash := HashPassword(password)
if !bytes.Equal(passwordHash, currentPassHash) {
return fmt.Errorf("invalid password")
}
return nil
}

277
client/utils/state.go Normal file
View File

@@ -0,0 +1,277 @@
package utils
import (
"encoding/hex"
"encoding/json"
"fmt"
"os"
"path/filepath"
"strconv"
"github.com/ark-network/ark/common"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/urfave/cli/v2"
)
const (
ASP_URL = "asp_url"
ASP_PUBKEY = "asp_public_key"
ROUND_LIFETIME = "round_lifetime"
UNILATERAL_EXIT_DELAY = "unilateral_exit_delay"
ENCRYPTED_PRVKEY = "encrypted_private_key"
PASSWORD_HASH = "password_hash"
PUBKEY = "public_key"
NETWORK = "network"
EXPLORER = "explorer"
MIN_RELAY_FEE = "min_relay_fee"
defaultNetwork = "liquid"
state_file = "state.json"
)
var initialState = map[string]string{
ASP_URL: "",
ASP_PUBKEY: "",
ROUND_LIFETIME: "",
UNILATERAL_EXIT_DELAY: "",
ENCRYPTED_PRVKEY: "",
PASSWORD_HASH: "",
PUBKEY: "",
NETWORK: defaultNetwork,
MIN_RELAY_FEE: "",
}
func GetNetwork(ctx *cli.Context) (*common.Network, error) {
state, err := GetState(ctx)
if err != nil {
return nil, err
}
net, ok := state[NETWORK]
if !ok {
return nil, fmt.Errorf("network not found in state")
}
return networkFromString(net), nil
}
func GetRoundLifetime(ctx *cli.Context) (int64, error) {
state, err := GetState(ctx)
if err != nil {
return -1, err
}
lifetime := state[ROUND_LIFETIME]
if len(lifetime) <= 0 {
return -1, fmt.Errorf("missing round lifetime")
}
roundLifetime, err := strconv.Atoi(lifetime)
if err != nil {
return -1, err
}
return int64(roundLifetime), nil
}
func GetMinRelayFee(ctx *cli.Context) (int64, error) {
state, err := GetState(ctx)
if err != nil {
return -1, err
}
fee := state[MIN_RELAY_FEE]
if len(fee) <= 0 {
return -1, fmt.Errorf("missing min relay fee")
}
minRelayFee, err := strconv.Atoi(fee)
if err != nil {
return -1, err
}
return int64(minRelayFee), nil
}
func GetUnilateralExitDelay(ctx *cli.Context) (int64, error) {
state, err := GetState(ctx)
if err != nil {
return -1, err
}
delay := state[UNILATERAL_EXIT_DELAY]
if len(delay) <= 0 {
return -1, fmt.Errorf("missing unilateral exit delay")
}
redeemDelay, err := strconv.Atoi(delay)
if err != nil {
return -1, err
}
return int64(redeemDelay), nil
}
func GetWalletPublicKey(ctx *cli.Context) (*secp256k1.PublicKey, error) {
state, err := GetState(ctx)
if err != nil {
return nil, err
}
publicKeyString := state[PUBKEY]
if len(publicKeyString) <= 0 {
return nil, fmt.Errorf("missing public key")
}
publicKeyBytes, err := hex.DecodeString(publicKeyString)
if err != nil {
return nil, err
}
return secp256k1.ParsePubKey(publicKeyBytes)
}
func GetAspPublicKey(ctx *cli.Context) (*secp256k1.PublicKey, error) {
state, err := GetState(ctx)
if err != nil {
return nil, err
}
arkPubKey := state[ASP_PUBKEY]
if len(arkPubKey) <= 0 {
return nil, fmt.Errorf("missing asp public key")
}
pubKeyBytes, err := hex.DecodeString(arkPubKey)
if err != nil {
return nil, err
}
return secp256k1.ParsePubKey(pubKeyBytes)
}
func GetState(ctx *cli.Context) (map[string]string, error) {
datadir := ctx.String("datadir")
stateFilePath := filepath.Join(datadir, state_file)
file, err := os.ReadFile(stateFilePath)
if err != nil {
if !os.IsNotExist(err) {
return nil, err
}
if err := setInitialState(stateFilePath); err != nil {
return nil, err
}
return initialState, nil
}
data := map[string]string{}
if err := json.Unmarshal(file, &data); err != nil {
return nil, err
}
return data, nil
}
func PrivateKeyFromPassword(ctx *cli.Context) (*secp256k1.PrivateKey, error) {
state, err := GetState(ctx)
if err != nil {
return nil, err
}
encryptedPrivateKeyString := state[ENCRYPTED_PRVKEY]
if len(encryptedPrivateKeyString) <= 0 {
return nil, fmt.Errorf("missing encrypted private key")
}
encryptedPrivateKey, err := hex.DecodeString(encryptedPrivateKeyString)
if err != nil {
return nil, fmt.Errorf("invalid encrypted private key: %s", err)
}
password, err := ReadPassword(ctx, true)
if err != nil {
return nil, err
}
fmt.Println("wallet unlocked")
cypher := NewAES128Cypher()
privateKeyBytes, err := cypher.decrypt(encryptedPrivateKey, password)
if err != nil {
return nil, err
}
privateKey := secp256k1.PrivKeyFromBytes(privateKeyBytes)
return privateKey, nil
}
func SetState(ctx *cli.Context, data map[string]string) error {
currentData, err := GetState(ctx)
if err != nil {
return err
}
mergedData := merge(currentData, data)
jsonString, err := json.Marshal(mergedData)
if err != nil {
return err
}
datadir := ctx.String("datadir")
statePath := filepath.Join(datadir, state_file)
err = os.WriteFile(statePath, jsonString, 0755)
if err != nil {
return fmt.Errorf("writing to file: %w", err)
}
return nil
}
func networkFromString(net string) *common.Network {
switch net {
case common.Liquid.Name:
return &common.Liquid
case common.LiquidTestNet.Name:
return &common.LiquidTestNet
case common.LiquidRegTest.Name:
return &common.LiquidRegTest
case common.Bitcoin.Name:
return &common.Bitcoin
case common.BitcoinTestNet.Name:
return &common.BitcoinTestNet
case common.BitcoinRegTest.Name:
return &common.BitcoinRegTest
default:
panic(fmt.Sprintf("unknown network (%s)", net))
}
}
func setInitialState(stateFilePath string) error {
jsonString, err := json.Marshal(initialState)
if err != nil {
return err
}
return os.WriteFile(stateFilePath, jsonString, 0755)
}
func getBaseURL(ctx *cli.Context) (string, error) {
state, err := GetState(ctx)
if err != nil {
return "", err
}
baseURL := state[EXPLORER]
if len(baseURL) <= 0 {
return "", fmt.Errorf("missing explorer base url")
}
return baseURL, nil
}
func merge(maps ...map[string]string) map[string]string {
merge := make(map[string]string, 0)
for _, m := range maps {
for k, v := range m {
merge[k] = v
}
}
return merge
}

View File

@@ -26,7 +26,7 @@ func CraftSharedOutput(
return nil, 0, err
}
root, err := createRootNode(aggregatedKey, aspPubkey, receivers, feeSatsPerNode, unilateralExitDelay)
root, err := createRootNode(aggregatedKey, cosigners, aspPubkey, receivers, feeSatsPerNode, unilateralExitDelay)
if err != nil {
return nil, 0, err
}
@@ -53,7 +53,7 @@ func CraftCongestionTree(
return nil, err
}
root, err := createRootNode(aggregatedKey, aspPubkey, receivers, feeSatsPerNode, unilateralExitDelay)
root, err := createRootNode(aggregatedKey, cosigners, aspPubkey, receivers, feeSatsPerNode, unilateralExitDelay)
if err != nil {
return nil, err
}
@@ -70,7 +70,7 @@ func CraftCongestionTree(
treeLevel := make([]tree.Node, 0)
for i, node := range nodes {
treeNode, err := getTreeNode(node, ins[i], schnorr.SerializePubKey(aggregatedKey.PreTweakedKey), sweepTapLeaf)
treeNode, err := getTreeNode(node, ins[i], schnorr.SerializePubKey(aggregatedKey.PreTweakedKey), sweepTapLeaf, cosigners)
if err != nil {
return nil, err
}
@@ -117,6 +117,7 @@ type leaf struct {
type branch struct {
aggregatedKey *musig2.AggregateKey
cosigners []*secp256k1.PublicKey
children []node
feeAmount int64
}
@@ -210,8 +211,9 @@ func getTreeNode(
input *wire.OutPoint,
inputTapInternalKey []byte,
inputSweepTapLeaf *psbt.TaprootTapLeafScript,
cosigners []*secp256k1.PublicKey,
) (tree.Node, error) {
partialTx, err := getTx(n, input, inputTapInternalKey, inputSweepTapLeaf)
partialTx, err := getTx(n, input, inputTapInternalKey, inputSweepTapLeaf, cosigners)
if err != nil {
return tree.Node{}, err
}
@@ -236,6 +238,7 @@ func getTx(
input *wire.OutPoint,
inputTapInternalKey []byte,
inputSweepTapLeaf *psbt.TaprootTapLeafScript,
cosigners []*secp256k1.PublicKey,
) (*psbt.Packet, error) {
outputs, err := n.getOutputs()
if err != nil {
@@ -259,11 +262,18 @@ func getTx(
tx.Inputs[0].TaprootInternalKey = inputTapInternalKey
tx.Inputs[0].TaprootLeafScript = []*psbt.TaprootTapLeafScript{inputSweepTapLeaf}
for _, cosigner := range cosigners {
if err := AddCosignerKey(0, tx, cosigner); err != nil {
return nil, err
}
}
return tx, nil
}
func createRootNode(
aggregatedKey *musig2.AggregateKey, aspPubkey *secp256k1.PublicKey, receivers []Receiver,
aggregatedKey *musig2.AggregateKey, cosigners []*secp256k1.PublicKey,
aspPubkey *secp256k1.PublicKey, receivers []Receiver,
feeSatsPerNode uint64, unilateralExitDelay int64,
) (root node, err error) {
if len(receivers) == 0 {
@@ -292,7 +302,7 @@ func createRootNode(
}
for len(nodes) > 1 {
nodes, err = createUpperLevel(nodes, aggregatedKey, int64(feeSatsPerNode))
nodes, err = createUpperLevel(nodes, aggregatedKey, cosigners, int64(feeSatsPerNode))
if err != nil {
return
}
@@ -342,10 +352,10 @@ func createAggregatedKeyWithSweep(
return aggregatedKey, tapLeaf, nil
}
func createUpperLevel(nodes []node, aggregatedKey *musig2.AggregateKey, feeAmount int64) ([]node, error) {
func createUpperLevel(nodes []node, aggregatedKey *musig2.AggregateKey, cosigners []*secp256k1.PublicKey, feeAmount int64) ([]node, error) {
if len(nodes)%2 != 0 {
last := nodes[len(nodes)-1]
pairs, err := createUpperLevel(nodes[:len(nodes)-1], aggregatedKey, feeAmount)
pairs, err := createUpperLevel(nodes[:len(nodes)-1], aggregatedKey, cosigners, feeAmount)
if err != nil {
return nil, err
}
@@ -359,6 +369,7 @@ func createUpperLevel(nodes []node, aggregatedKey *musig2.AggregateKey, feeAmoun
right := nodes[i+1]
branchNode := &branch{
aggregatedKey: aggregatedKey,
cosigners: cosigners,
feeAmount: feeAmount,
children: []node{left, right},
}

View File

@@ -12,7 +12,6 @@ import (
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
)
var (
@@ -24,9 +23,9 @@ type TreeNonces [][][66]byte // public nonces
type TreePartialSigs [][]*musig2.PartialSignature
type SignerSession interface {
GetNonces(*btcec.PublicKey) (TreeNonces, error) // generate of return cached nonce for this session
GetNonces() (TreeNonces, error) // generate of return cached nonce for this session
SetKeys([]*btcec.PublicKey, TreeNonces) error // set the keys for this session (with the combined nonces)
Sign(*btcec.PrivateKey) (TreePartialSigs, error) // sign the tree
Sign() (TreePartialSigs, error) // sign the tree
}
type CoordinatorSession interface {
@@ -158,11 +157,13 @@ func (n TreePartialSigs) Encode(w io.Writer) error {
}
func NewTreeSignerSession(
signer *btcec.PrivateKey,
congestionTree tree.CongestionTree,
minRelayFee int64,
scriptRoot []byte,
) SignerSession {
return &treeSignerSession{
secretKey: signer,
tree: congestionTree,
minRelayFee: minRelayFee,
scriptRoot: scriptRoot,
@@ -170,6 +171,7 @@ func NewTreeSignerSession(
}
type treeSignerSession struct {
secretKey *btcec.PrivateKey
tree tree.CongestionTree
myNonces [][]*musig2.Nonces
keys []*btcec.PublicKey
@@ -179,7 +181,7 @@ type treeSignerSession struct {
prevoutFetcher func(*psbt.Packet) txscript.PrevOutputFetcher
}
func (t *treeSignerSession) generateNonces(key *btcec.PublicKey) error {
func (t *treeSignerSession) generateNonces() error {
if t.tree == nil {
return ErrCongestionTreeNotSet
}
@@ -190,7 +192,7 @@ func (t *treeSignerSession) generateNonces(key *btcec.PublicKey) error {
levelNonces := make([]*musig2.Nonces, 0)
for range level {
nonce, err := musig2.GenNonces(
musig2.WithPublicKey(key),
musig2.WithPublicKey(t.secretKey.PubKey()),
)
if err != nil {
return err
@@ -205,13 +207,13 @@ func (t *treeSignerSession) generateNonces(key *btcec.PublicKey) error {
return nil
}
func (t *treeSignerSession) GetNonces(key *btcec.PublicKey) (TreeNonces, error) {
func (t *treeSignerSession) GetNonces() (TreeNonces, error) {
if t.tree == nil {
return nil, ErrCongestionTreeNotSet
}
if t.myNonces == nil {
if err := t.generateNonces(key); err != nil {
if err := t.generateNonces(); err != nil {
return nil, err
}
}
@@ -255,7 +257,7 @@ func (t *treeSignerSession) SetKeys(keys []*btcec.PublicKey, nonces TreeNonces)
return nil
}
func (t *treeSignerSession) Sign(seckey *secp256k1.PrivateKey) (TreePartialSigs, error) {
func (t *treeSignerSession) Sign() (TreePartialSigs, error) {
if t.tree == nil {
return nil, ErrCongestionTreeNotSet
}
@@ -279,7 +281,7 @@ func (t *treeSignerSession) Sign(seckey *secp256k1.PrivateKey) (TreePartialSigs,
return nil, err
}
// sign the node
sig, err := t.signPartial(partialTx, i, j, seckey)
sig, err := t.signPartial(partialTx, i, j, t.secretKey)
if err != nil {
return nil, err
}
@@ -336,12 +338,14 @@ func NewTreeCoordinatorSession(congestionTree tree.CongestionTree, minRelayFee i
return nil, err
}
nbOfKeys := len(keys)
return &treeCoordinatorSession{
scriptRoot: scriptRoot,
tree: congestionTree,
keys: keys,
nonces: make([]TreeNonces, len(keys)),
sigs: make([]TreePartialSigs, len(keys)),
nonces: make([]TreeNonces, nbOfKeys),
sigs: make([]TreePartialSigs, nbOfKeys),
prevoutFetcher: prevoutFetcher,
}, nil
}

View File

@@ -72,17 +72,17 @@ func TestRoundTripSignTree(t *testing.T) {
)
require.NoError(t, err)
aliceSession := bitcointree.NewTreeSignerSession(tree, minRelayFee, root.CloneBytes())
bobSession := bitcointree.NewTreeSignerSession(tree, minRelayFee, root.CloneBytes())
aspSession := bitcointree.NewTreeSignerSession(tree, minRelayFee, root.CloneBytes())
aliceSession := bitcointree.NewTreeSignerSession(alice, tree, minRelayFee, root.CloneBytes())
bobSession := bitcointree.NewTreeSignerSession(bob, tree, minRelayFee, root.CloneBytes())
aspSession := bitcointree.NewTreeSignerSession(asp, tree, minRelayFee, root.CloneBytes())
aliceNonces, err := aliceSession.GetNonces(alice.PubKey())
aliceNonces, err := aliceSession.GetNonces()
require.NoError(t, err)
bobNonces, err := bobSession.GetNonces(bob.PubKey())
bobNonces, err := bobSession.GetNonces()
require.NoError(t, err)
aspNonces, err := aspSession.GetNonces(asp.PubKey())
aspNonces, err := aspSession.GetNonces()
require.NoError(t, err)
err = aspCoordinator.AddNonce(alice.PubKey(), aliceNonces)
@@ -117,13 +117,13 @@ func TestRoundTripSignTree(t *testing.T) {
)
require.NoError(t, err)
aliceSig, err := aliceSession.Sign(alice)
aliceSig, err := aliceSession.Sign()
require.NoError(t, err)
bobSig, err := bobSession.Sign(bob)
bobSig, err := bobSession.Sign()
require.NoError(t, err)
aspSig, err := aspSession.Sign(asp)
aspSig, err := aspSession.Sign()
require.NoError(t, err)
// coordinator receives the signatures and combines them

View File

@@ -0,0 +1,59 @@
package bitcointree
import (
"bytes"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
)
var (
COSIGNER_PSBT_KEY_PREFIX = []byte("cosigner")
)
func AddCosignerKey(inIndex int, ptx *psbt.Packet, key *secp256k1.PublicKey) error {
currentCosigners, err := GetCosignerKeys(ptx.Inputs[inIndex])
if err != nil {
return err
}
nextCosignerIndex := len(currentCosigners)
ptx.Inputs[inIndex].Unknowns = append(ptx.Inputs[inIndex].Unknowns, &psbt.Unknown{
Value: key.SerializeCompressed(),
Key: cosignerPrefixedKey(nextCosignerIndex),
})
return nil
}
func GetCosignerKeys(in psbt.PInput) ([]*secp256k1.PublicKey, error) {
var keys []*secp256k1.PublicKey
for _, u := range in.Unknowns {
cosignerIndex := parsePrefixedCosignerKey(u.Key)
if cosignerIndex == -1 {
continue
}
key, err := secp256k1.ParsePubKey(u.Value)
if err != nil {
return nil, err
}
keys = append(keys, key)
}
return keys, nil
}
func cosignerPrefixedKey(index int) []byte {
return append(COSIGNER_PSBT_KEY_PREFIX, byte(index))
}
func parsePrefixedCosignerKey(key []byte) int {
if !bytes.HasPrefix(key, COSIGNER_PSBT_KEY_PREFIX) {
return -1
}
return int(key[len(COSIGNER_PSBT_KEY_PREFIX)])
}

View File

@@ -8,7 +8,6 @@ import (
"github.com/ark-network/ark/common/tree"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
@@ -74,7 +73,7 @@ func UnspendableKey() *secp256k1.PublicKey {
// - input and output amounts
func ValidateCongestionTree(
tree tree.CongestionTree, poolTx string, aspPublicKey *secp256k1.PublicKey,
roundLifetime int64, cosigners []*secp256k1.PublicKey, minRelayFee int64,
roundLifetime int64, minRelayFee int64,
) error {
poolTransaction, err := psbt.NewFromRawBytes(strings.NewReader(poolTx), true)
if err != nil {
@@ -139,17 +138,11 @@ func ValidateCongestionTree(
tapTree := txscript.AssembleTaprootScriptTree(*sweepLeaf)
root := tapTree.RootNode.TapHash()
signers := append(cosigners, aspPublicKey)
aggregatedKey, err := AggregateKeys(signers, root[:])
if err != nil {
return err
}
// iterates over all the nodes of the tree
for _, level := range tree {
for _, node := range level {
if err := validateNodeTransaction(
node, tree, aggregatedKey, minRelayFee,
node, tree, root.CloneBytes(), minRelayFee,
); err != nil {
return err
}
@@ -159,10 +152,7 @@ func ValidateCongestionTree(
return nil
}
func validateNodeTransaction(
node tree.Node, tree tree.CongestionTree,
expectedAggregatedKey *musig2.AggregateKey, minRelayFee int64,
) error {
func validateNodeTransaction(node tree.Node, tree tree.CongestionTree, tapTreeRoot []byte, minRelayFee int64) error {
if node.Tx == "" {
return ErrNodeTransactionEmpty
}
@@ -175,25 +165,25 @@ func validateNodeTransaction(
return ErrNodeParentTxidEmpty
}
decodedPset, err := psbt.NewFromRawBytes(strings.NewReader(node.Tx), true)
decodedPsbt, err := psbt.NewFromRawBytes(strings.NewReader(node.Tx), true)
if err != nil {
return fmt.Errorf("invalid node transaction: %w", err)
}
if decodedPset.UnsignedTx.TxHash().String() != node.Txid {
if decodedPsbt.UnsignedTx.TxHash().String() != node.Txid {
return ErrNodeTxidDifferent
}
if len(decodedPset.Inputs) != 1 {
if len(decodedPsbt.Inputs) != 1 {
return ErrNumberOfInputs
}
input := decodedPset.Inputs[0]
input := decodedPsbt.Inputs[0]
if len(input.TaprootLeafScript) != 1 {
return ErrNumberOfTapscripts
}
prevTxid := decodedPset.UnsignedTx.TxIn[0].PreviousOutPoint.Hash.String()
prevTxid := decodedPsbt.UnsignedTx.TxIn[0].PreviousOutPoint.Hash.String()
if prevTxid != node.ParentTxid {
return ErrParentTxidInput
}
@@ -210,20 +200,30 @@ func validateNodeTransaction(
return fmt.Errorf("invalid child transaction: %w", err)
}
parentOutput := decodedPset.UnsignedTx.TxOut[childIndex]
parentOutput := decodedPsbt.UnsignedTx.TxOut[childIndex]
previousScriptKey := parentOutput.PkScript[2:]
if len(previousScriptKey) != 32 {
return ErrInvalidTaprootScript
}
inputData := decodedPset.Inputs[0]
inputData := decodedPsbt.Inputs[0]
inputTapInternalKey, err := schnorr.ParsePubKey(inputData.TaprootInternalKey)
if err != nil {
return fmt.Errorf("invalid internal key: %w", err)
}
if !bytes.Equal(inputData.TaprootInternalKey, schnorr.SerializePubKey(expectedAggregatedKey.PreTweakedKey)) {
cosigners, err := GetCosignerKeys(decodedPsbt.Inputs[0])
if err != nil {
return fmt.Errorf("unable to get cosigners keys: %w", err)
}
aggregatedKey, err := AggregateKeys(cosigners, tapTreeRoot)
if err != nil {
return fmt.Errorf("unable to aggregate keys: %w", err)
}
if !bytes.Equal(inputData.TaprootInternalKey, schnorr.SerializePubKey(aggregatedKey.PreTweakedKey)) {
return ErrInternalKey
}
@@ -237,7 +237,7 @@ func validateNodeTransaction(
rootHash := ctrlBlock.RootHash(inputTapLeaf.Script)
tapKey := txscript.ComputeTaprootOutputKey(inputTapInternalKey, rootHash)
if !bytes.Equal(schnorr.SerializePubKey(tapKey), schnorr.SerializePubKey(expectedAggregatedKey.FinalKey)) {
if !bytes.Equal(schnorr.SerializePubKey(tapKey), schnorr.SerializePubKey(aggregatedKey.FinalKey)) {
return ErrInvalidTaprootScript
}

View File

@@ -1,10 +1,10 @@
module github.com/ark-network/ark/common
go 1.21.0
go 1.22.2
require (
github.com/btcsuite/btcd v0.24.2
github.com/btcsuite/btcd/btcec/v2 v2.3.4
github.com/btcsuite/btcd/btcec/v2 v2.3.3
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/btcsuite/btcd/btcutil/psbt v1.1.9
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0

View File

@@ -6,8 +6,8 @@ github.com/btcsuite/btcd v0.24.2 h1:aLmxPguqxza+4ag8R1I2nnJjSu2iFn/kqtHTIImswcY=
github.com/btcsuite/btcd v0.24.2/go.mod h1:5C8ChTkl5ejr3WHj8tkQSCmydiMEPB0ZhQhehpq7Dgg=
github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/btcec/v2 v2.3.3 h1:6+iXlDKE8RMtKsvK0gshlXIuPbyWM/h84Ensb7o3sC0=
github.com/btcsuite/btcd/btcec/v2 v2.3.3/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A=
github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE=
github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdisflzM8=

View File

@@ -1,40 +0,0 @@
package common
import (
"fmt"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/vulpemventures/go-elements/psetv2"
)
// TaprootPreimage computes the hash for witness v1 input of a pset
// it implicitly assumes that the pset has witnessUtxo fields populated
func TaprootPreimage(
genesisBlockHash *chainhash.Hash, pset *psetv2.Pset, inputIndex int,
leafHash *chainhash.Hash,
) ([]byte, error) {
prevoutScripts := make([][]byte, 0)
prevoutAssets := make([][]byte, 0)
prevoutValues := make([][]byte, 0)
for i, input := range pset.Inputs {
if input.WitnessUtxo == nil {
return nil, fmt.Errorf("missing witness utxo on input #%d", i)
}
prevoutScripts = append(prevoutScripts, input.WitnessUtxo.Script)
prevoutAssets = append(prevoutAssets, input.WitnessUtxo.Asset)
prevoutValues = append(prevoutValues, input.WitnessUtxo.Value)
}
utx, err := pset.UnsignedTx()
if err != nil {
return nil, err
}
preimage := utx.HashForWitnessV1(
inputIndex, prevoutScripts, prevoutAssets, prevoutValues,
pset.Inputs[inputIndex].SigHashType, genesisBlockHash, leafHash, nil,
)
return preimage[:], nil
}

View File

@@ -2,9 +2,6 @@ package tree
import (
"errors"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/vulpemventures/go-elements/psetv2"
)
// Node is a struct embedding the transaction and the parent txid of a congestion tree node
@@ -105,37 +102,6 @@ func (c CongestionTree) Branch(vtxoTxid string) ([]Node, error) {
return branch, nil
}
// FindLeaves returns all the leaves that are reachable from the given node output
func (c CongestionTree) FindLeaves(fromtxid string, vout uint32) ([]Node, error) {
allLeaves := c.Leaves()
foundLeaves := make([]Node, 0)
for _, leaf := range allLeaves {
branch, err := c.Branch(leaf.Txid)
if err != nil {
return nil, err
}
for _, node := range branch {
pset, err := psetv2.NewPsetFromBase64(node.Tx)
if err != nil {
return nil, err
}
input := pset.Inputs[0]
txid := chainhash.Hash(input.PreviousTxid).String()
index := input.PreviousTxIndex
if txid == fromtxid && index == vout {
foundLeaves = append(foundLeaves, leaf)
break
}
}
}
return foundLeaves, nil
}
func (n Node) findParent(tree CongestionTree) (Node, error) {
for _, level := range tree {
for _, node := range level {

View File

@@ -0,0 +1,30 @@
services:
clarkd:
container_name: clarkd
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
environment:
- ARK_ROUND_INTERVAL=10
- ARK_NETWORK=regtest
- ARK_LOG_LEVEL=5
- ARK_ROUND_LIFETIME=512
- ARK_TX_BUILDER_TYPE=covenantless
- ARK_MIN_RELAY_FEE=200
- ARK_NEUTRINO_PEER=bitcoin:18444
- ARK_ESPLORA_URL=http://chopsticks:3000
- ARK_WALLET_PASSWORD=password
ports:
- "6000:6000"
volumes:
clarkd:
external: false
clark:
external: false
networks:
default:
name: nigiri
external: true

View File

@@ -1,5 +1,3 @@
version: "3.7"
services:
oceand:
container_name: oceand
@@ -31,6 +29,7 @@ services:
- ARK_LOG_LEVEL=5
- ARK_ROUND_LIFETIME=512
- ARK_DB_TYPE=sqlite
- ARK_TX_BUILDER_TYPE=covenant
ports:
- "8080:6000"

View File

@@ -29,7 +29,7 @@ services:
environment:
- ARK_WALLET_ADDR=oceand:18000
- ARK_ROUND_INTERVAL=10
- ARK_NETWORK=testnet
- ARK_NETWORK=liquidtestnet
ports:
- "8080:6000"
volumes:

View File

@@ -43,7 +43,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/vulpemventures/fastsha256 v0.0.0-20160815193821-637e65642941 // indirect
github.com/vulpemventures/go-elements v0.5.3 // indirect
github.com/vulpemventures/go-elements v0.5.4 // indirect
go.mongodb.org/mongo-driver v1.14.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
@@ -53,9 +53,9 @@ require (
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

View File

@@ -130,8 +130,8 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/vulpemventures/fastsha256 v0.0.0-20160815193821-637e65642941 h1:CTcw80hz/Sw8hqlKX5ZYvBUF5gAHSHwdjXxRf/cjDcI=
github.com/vulpemventures/fastsha256 v0.0.0-20160815193821-637e65642941/go.mod h1:GXBJykxW2kUcktGdsgyay7uwwWvkljASfljNcT0mbh8=
github.com/vulpemventures/go-elements v0.5.3 h1:zaC/ynHFwCAzFSOMfzb6BcbD6FXASppSiGMycc95WVA=
github.com/vulpemventures/go-elements v0.5.3/go.mod h1:aBGuWXHaiAIUIcwqCdtEh2iQ3kJjKwHU9ywvhlcRSeU=
github.com/vulpemventures/go-elements v0.5.4 h1:l94xoa9aYPPWiOB7Pmi08rKYvdk/n/sQIbLkQfEAASc=
github.com/vulpemventures/go-elements v0.5.4/go.mod h1:Tvhb+rZWv3lxoI5CdK03J3V+e2QVr/7UAnCYILxFSq4=
github.com/vulpemventures/go-secp256k1-zkp v1.1.6 h1:BmsrmXRLUibwa75Qkk8yELjpzCzlAjYFGLiLiOdq7Xo=
github.com/vulpemventures/go-secp256k1-zkp v1.1.6/go.mod h1:zo7CpgkuPgoe7fAV+inyxsI9IhGmcoFgyD8nqZaPSOM=
go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80=
@@ -179,10 +179,10 @@ golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d h1:Aqf0fiIdUQEj0Gn9mKFFXoQfTTEaNopWpfVyYADxiSg=
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Od4k8V1LQSizPRUK4OzZ7TBE/20k+jPczUDAEyvn69Y=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d h1:k3zyW3BYYR30e8v3x0bTDdE9vpYFjZHK+HcyqkrppWk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
@@ -191,8 +191,8 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

View File

@@ -20,7 +20,7 @@ require (
github.com/go-openapi/validate v0.24.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.9.0
github.com/vulpemventures/go-elements v0.5.3
github.com/vulpemventures/go-elements v0.5.4
golang.org/x/crypto v0.25.0
google.golang.org/grpc v1.65.0
)
@@ -52,12 +52,12 @@ require (
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/protobuf v1.34.1 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

View File

@@ -130,8 +130,8 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/vulpemventures/fastsha256 v0.0.0-20160815193821-637e65642941 h1:CTcw80hz/Sw8hqlKX5ZYvBUF5gAHSHwdjXxRf/cjDcI=
github.com/vulpemventures/fastsha256 v0.0.0-20160815193821-637e65642941/go.mod h1:GXBJykxW2kUcktGdsgyay7uwwWvkljASfljNcT0mbh8=
github.com/vulpemventures/go-elements v0.5.3 h1:zaC/ynHFwCAzFSOMfzb6BcbD6FXASppSiGMycc95WVA=
github.com/vulpemventures/go-elements v0.5.3/go.mod h1:aBGuWXHaiAIUIcwqCdtEh2iQ3kJjKwHU9ywvhlcRSeU=
github.com/vulpemventures/go-elements v0.5.4 h1:l94xoa9aYPPWiOB7Pmi08rKYvdk/n/sQIbLkQfEAASc=
github.com/vulpemventures/go-elements v0.5.4/go.mod h1:Tvhb+rZWv3lxoI5CdK03J3V+e2QVr/7UAnCYILxFSq4=
github.com/vulpemventures/go-secp256k1-zkp v1.1.6 h1:BmsrmXRLUibwa75Qkk8yELjpzCzlAjYFGLiLiOdq7Xo=
github.com/vulpemventures/go-secp256k1-zkp v1.1.6/go.mod h1:zo7CpgkuPgoe7fAV+inyxsI9IhGmcoFgyD8nqZaPSOM=
go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80=
@@ -154,8 +154,8 @@ golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
@@ -179,10 +179,10 @@ golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d h1:Aqf0fiIdUQEj0Gn9mKFFXoQfTTEaNopWpfVyYADxiSg=
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Od4k8V1LQSizPRUK4OzZ7TBE/20k+jPczUDAEyvn69Y=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d h1:k3zyW3BYYR30e8v3x0bTDdE9vpYFjZHK+HcyqkrppWk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
@@ -191,8 +191,8 @@ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQ
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

View File

@@ -23,7 +23,7 @@ help:
## intergrationtest: runs integration tests
integrationtest:
@echo "Running integration tests..."
@go test -v -count=1 -race -timeout 200s github.com/ark-network/ark/test/e2e
@go test -v -count=1 -race -timeout 200s github.com/ark-network/ark/test/e2e/...
## lint: lint codebase
lint:

View File

@@ -16,6 +16,28 @@
"application/json"
],
"paths": {
"/v1/admin/address": {
"get": {
"operationId": "AdminService_GetWalletAddress",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1GetWalletAddressResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"AdminService"
]
}
},
"/v1/admin/balance": {
"get": {
"operationId": "AdminService_GetBalance",
@@ -100,6 +122,28 @@
]
}
},
"/v1/admin/status": {
"get": {
"operationId": "AdminService_GetWalletStatus",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1GetWalletStatusResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"tags": [
"AdminService"
]
}
},
"/v1/admin/sweeps": {
"get": {
"operationId": "AdminService_GetScheduledSweep",
@@ -251,6 +295,28 @@
}
}
},
"v1GetWalletAddressResponse": {
"type": "object",
"properties": {
"address": {
"type": "string"
}
}
},
"v1GetWalletStatusResponse": {
"type": "object",
"properties": {
"initialized": {
"type": "boolean"
},
"unlocked": {
"type": "boolean"
},
"synced": {
"type": "boolean"
}
}
},
"v1ScheduledSweep": {
"type": "object",
"properties": {

View File

@@ -26,6 +26,16 @@ service AdminService {
body: "*"
};
}
rpc GetWalletAddress(GetWalletAddressRequest) returns (GetWalletAddressResponse) {
option (google.api.http) = {
get: "/v1/admin/address"
};
}
rpc GetWalletStatus(GetWalletStatusRequest) returns (GetWalletStatusResponse) {
option (google.api.http) = {
get: "/v1/admin/status"
};
}
}
message GetBalanceRequest {}
@@ -82,3 +92,20 @@ message GetRoundsRequest {
message GetRoundsResponse {
repeated string rounds = 1;
}
message GetWalletAddressRequest {}
message GetWalletAddressResponse {
string address = 1;
}
message GetWalletBalanceRequest {}
message GetWalletBalanceResponse {
uint64 balance = 1;
}
message GetWalletStatusRequest {}
message GetWalletStatusResponse {
bool initialized = 1;
bool unlocked = 2;
bool synced = 3;
}

View File

@@ -640,6 +640,277 @@ func (x *GetRoundsResponse) GetRounds() []string {
return nil
}
type GetWalletAddressRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *GetWalletAddressRequest) Reset() {
*x = GetWalletAddressRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_ark_v1_admin_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetWalletAddressRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetWalletAddressRequest) ProtoMessage() {}
func (x *GetWalletAddressRequest) ProtoReflect() protoreflect.Message {
mi := &file_ark_v1_admin_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetWalletAddressRequest.ProtoReflect.Descriptor instead.
func (*GetWalletAddressRequest) Descriptor() ([]byte, []int) {
return file_ark_v1_admin_proto_rawDescGZIP(), []int{11}
}
type GetWalletAddressResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
}
func (x *GetWalletAddressResponse) Reset() {
*x = GetWalletAddressResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_ark_v1_admin_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetWalletAddressResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetWalletAddressResponse) ProtoMessage() {}
func (x *GetWalletAddressResponse) ProtoReflect() protoreflect.Message {
mi := &file_ark_v1_admin_proto_msgTypes[12]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetWalletAddressResponse.ProtoReflect.Descriptor instead.
func (*GetWalletAddressResponse) Descriptor() ([]byte, []int) {
return file_ark_v1_admin_proto_rawDescGZIP(), []int{12}
}
func (x *GetWalletAddressResponse) GetAddress() string {
if x != nil {
return x.Address
}
return ""
}
type GetWalletBalanceRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *GetWalletBalanceRequest) Reset() {
*x = GetWalletBalanceRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_ark_v1_admin_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetWalletBalanceRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetWalletBalanceRequest) ProtoMessage() {}
func (x *GetWalletBalanceRequest) ProtoReflect() protoreflect.Message {
mi := &file_ark_v1_admin_proto_msgTypes[13]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetWalletBalanceRequest.ProtoReflect.Descriptor instead.
func (*GetWalletBalanceRequest) Descriptor() ([]byte, []int) {
return file_ark_v1_admin_proto_rawDescGZIP(), []int{13}
}
type GetWalletBalanceResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Balance uint64 `protobuf:"varint,1,opt,name=balance,proto3" json:"balance,omitempty"`
}
func (x *GetWalletBalanceResponse) Reset() {
*x = GetWalletBalanceResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_ark_v1_admin_proto_msgTypes[14]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetWalletBalanceResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetWalletBalanceResponse) ProtoMessage() {}
func (x *GetWalletBalanceResponse) ProtoReflect() protoreflect.Message {
mi := &file_ark_v1_admin_proto_msgTypes[14]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetWalletBalanceResponse.ProtoReflect.Descriptor instead.
func (*GetWalletBalanceResponse) Descriptor() ([]byte, []int) {
return file_ark_v1_admin_proto_rawDescGZIP(), []int{14}
}
func (x *GetWalletBalanceResponse) GetBalance() uint64 {
if x != nil {
return x.Balance
}
return 0
}
type GetWalletStatusRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *GetWalletStatusRequest) Reset() {
*x = GetWalletStatusRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_ark_v1_admin_proto_msgTypes[15]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetWalletStatusRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetWalletStatusRequest) ProtoMessage() {}
func (x *GetWalletStatusRequest) ProtoReflect() protoreflect.Message {
mi := &file_ark_v1_admin_proto_msgTypes[15]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetWalletStatusRequest.ProtoReflect.Descriptor instead.
func (*GetWalletStatusRequest) Descriptor() ([]byte, []int) {
return file_ark_v1_admin_proto_rawDescGZIP(), []int{15}
}
type GetWalletStatusResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Initialized bool `protobuf:"varint,1,opt,name=initialized,proto3" json:"initialized,omitempty"`
Unlocked bool `protobuf:"varint,2,opt,name=unlocked,proto3" json:"unlocked,omitempty"`
Synced bool `protobuf:"varint,3,opt,name=synced,proto3" json:"synced,omitempty"`
}
func (x *GetWalletStatusResponse) Reset() {
*x = GetWalletStatusResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_ark_v1_admin_proto_msgTypes[16]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetWalletStatusResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetWalletStatusResponse) ProtoMessage() {}
func (x *GetWalletStatusResponse) ProtoReflect() protoreflect.Message {
mi := &file_ark_v1_admin_proto_msgTypes[16]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetWalletStatusResponse.ProtoReflect.Descriptor instead.
func (*GetWalletStatusResponse) Descriptor() ([]byte, []int) {
return file_ark_v1_admin_proto_rawDescGZIP(), []int{16}
}
func (x *GetWalletStatusResponse) GetInitialized() bool {
if x != nil {
return x.Initialized
}
return false
}
func (x *GetWalletStatusResponse) GetUnlocked() bool {
if x != nil {
return x.Unlocked
}
return false
}
func (x *GetWalletStatusResponse) GetSynced() bool {
if x != nil {
return x.Synced
}
return false
}
var File_ark_v1_admin_proto protoreflect.FileDescriptor
var file_ark_v1_admin_proto_rawDesc = []byte{
@@ -712,45 +983,78 @@ var file_ark_v1_admin_proto_rawDesc = []byte{
0x6f, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x62, 0x65, 0x66, 0x6f, 0x72,
0x65, 0x22, 0x2b, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x73,
0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x32, 0xb9,
0x03, 0x0a, 0x0c, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
0x5e, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x19, 0x2e,
0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76,
0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x76,
0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12,
0x72, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x64, 0x53,
0x77, 0x65, 0x65, 0x70, 0x12, 0x20, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65,
0x74, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x64, 0x53, 0x77, 0x65, 0x65, 0x70, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e,
0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x22, 0x19,
0x0a, 0x17, 0x47, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65,
0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x34, 0x0a, 0x18, 0x47, 0x65, 0x74,
0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22,
0x19, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61,
0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x34, 0x0a, 0x18, 0x47, 0x65,
0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65,
0x22, 0x18, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x53, 0x74, 0x61,
0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x6f, 0x0a, 0x17, 0x47, 0x65,
0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c,
0x69, 0x7a, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x6e, 0x69, 0x74,
0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x6e, 0x6c, 0x6f, 0x63,
0x6b, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x75, 0x6e, 0x6c, 0x6f, 0x63,
0x6b, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x79, 0x6e, 0x63, 0x65, 0x64, 0x18, 0x03, 0x20,
0x01, 0x28, 0x08, 0x52, 0x06, 0x73, 0x79, 0x6e, 0x63, 0x65, 0x64, 0x32, 0x99, 0x05, 0x0a, 0x0c,
0x41, 0x64, 0x6d, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5e, 0x0a, 0x0a,
0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x19, 0x2e, 0x61, 0x72, 0x6b,
0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47,
0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x76, 0x31, 0x2f, 0x61,
0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x72, 0x0a, 0x11,
0x47, 0x65, 0x74, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x64, 0x53, 0x77, 0x65, 0x65,
0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02,
0x12, 0x12, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x73, 0x77, 0x65,
0x65, 0x70, 0x73, 0x12, 0x76, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x44,
0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x1e, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e,
0x47, 0x65, 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e,
0x47, 0x65, 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x12,
0x1a, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x72, 0x6f, 0x75, 0x6e, 0x64,
0x2f, 0x7b, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x7d, 0x12, 0x5d, 0x0a, 0x09, 0x47,
0x65, 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x12, 0x18, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76,
0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x19, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52,
0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82,
0xd3, 0xe4, 0x93, 0x02, 0x15, 0x3a, 0x01, 0x2a, 0x22, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x64,
0x6d, 0x69, 0x6e, 0x2f, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x42, 0x90, 0x01, 0x0a, 0x0a, 0x63,
0x6f, 0x6d, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x41, 0x64, 0x6d, 0x69, 0x6e,
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x6b, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f,
0x61, 0x72, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2d, 0x73, 0x70, 0x65, 0x63, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x72, 0x6b, 0x2f, 0x76, 0x31,
0x3b, 0x61, 0x72, 0x6b, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x41, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x41,
0x72, 0x6b, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x06, 0x41, 0x72, 0x6b, 0x5c, 0x56, 0x31, 0xe2, 0x02,
0x12, 0x41, 0x72, 0x6b, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64,
0x61, 0x74, 0x61, 0xea, 0x02, 0x07, 0x41, 0x72, 0x6b, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
0x70, 0x12, 0x20, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x63,
0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x64, 0x53, 0x77, 0x65, 0x65, 0x70, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74,
0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x64, 0x53, 0x77, 0x65, 0x65, 0x70, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10,
0x2f, 0x76, 0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x73, 0x77, 0x65, 0x65, 0x70, 0x73,
0x12, 0x76, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x44, 0x65, 0x74, 0x61,
0x69, 0x6c, 0x73, 0x12, 0x1e, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74,
0x52, 0x6f, 0x75, 0x6e, 0x64, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74,
0x52, 0x6f, 0x75, 0x6e, 0x64, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x12, 0x1a, 0x2f, 0x76,
0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2f, 0x7b, 0x72,
0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x7d, 0x12, 0x5d, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x52,
0x6f, 0x75, 0x6e, 0x64, 0x73, 0x12, 0x18, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47,
0x65, 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x19, 0x2e, 0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x75, 0x6e,
0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93,
0x02, 0x15, 0x3a, 0x01, 0x2a, 0x22, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e,
0x2f, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x12, 0x70, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x57, 0x61,
0x6c, 0x6c, 0x65, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1f, 0x2e, 0x61, 0x72,
0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x41, 0x64,
0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x61,
0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x41,
0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19,
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69,
0x6e, 0x2f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x6c, 0x0a, 0x0f, 0x47, 0x65, 0x74,
0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1e, 0x2e, 0x61,
0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x53,
0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x61,
0x72, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x53,
0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x82,
0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e,
0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x90, 0x01, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e,
0x61, 0x72, 0x6b, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x50, 0x72, 0x6f,
0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x61, 0x72, 0x6b, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x61, 0x72, 0x6b,
0x2f, 0x61, 0x70, 0x69, 0x2d, 0x73, 0x70, 0x65, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x72, 0x6b, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x72,
0x6b, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x41, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x41, 0x72, 0x6b, 0x2e,
0x56, 0x31, 0xca, 0x02, 0x06, 0x41, 0x72, 0x6b, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x12, 0x41, 0x72,
0x6b, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
0xea, 0x02, 0x07, 0x41, 0x72, 0x6b, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (
@@ -765,7 +1069,7 @@ func file_ark_v1_admin_proto_rawDescGZIP() []byte {
return file_ark_v1_admin_proto_rawDescData
}
var file_ark_v1_admin_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_ark_v1_admin_proto_msgTypes = make([]protoimpl.MessageInfo, 17)
var file_ark_v1_admin_proto_goTypes = []interface{}{
(*GetBalanceRequest)(nil), // 0: ark.v1.GetBalanceRequest
(*Balance)(nil), // 1: ark.v1.Balance
@@ -778,6 +1082,12 @@ var file_ark_v1_admin_proto_goTypes = []interface{}{
(*GetRoundDetailsResponse)(nil), // 8: ark.v1.GetRoundDetailsResponse
(*GetRoundsRequest)(nil), // 9: ark.v1.GetRoundsRequest
(*GetRoundsResponse)(nil), // 10: ark.v1.GetRoundsResponse
(*GetWalletAddressRequest)(nil), // 11: ark.v1.GetWalletAddressRequest
(*GetWalletAddressResponse)(nil), // 12: ark.v1.GetWalletAddressResponse
(*GetWalletBalanceRequest)(nil), // 13: ark.v1.GetWalletBalanceRequest
(*GetWalletBalanceResponse)(nil), // 14: ark.v1.GetWalletBalanceResponse
(*GetWalletStatusRequest)(nil), // 15: ark.v1.GetWalletStatusRequest
(*GetWalletStatusResponse)(nil), // 16: ark.v1.GetWalletStatusResponse
}
var file_ark_v1_admin_proto_depIdxs = []int32{
1, // 0: ark.v1.GetBalanceResponse.main_account:type_name -> ark.v1.Balance
@@ -788,12 +1098,16 @@ var file_ark_v1_admin_proto_depIdxs = []int32{
3, // 5: ark.v1.AdminService.GetScheduledSweep:input_type -> ark.v1.GetScheduledSweepRequest
7, // 6: ark.v1.AdminService.GetRoundDetails:input_type -> ark.v1.GetRoundDetailsRequest
9, // 7: ark.v1.AdminService.GetRounds:input_type -> ark.v1.GetRoundsRequest
2, // 8: ark.v1.AdminService.GetBalance:output_type -> ark.v1.GetBalanceResponse
6, // 9: ark.v1.AdminService.GetScheduledSweep:output_type -> ark.v1.GetScheduledSweepResponse
8, // 10: ark.v1.AdminService.GetRoundDetails:output_type -> ark.v1.GetRoundDetailsResponse
10, // 11: ark.v1.AdminService.GetRounds:output_type -> ark.v1.GetRoundsResponse
8, // [8:12] is the sub-list for method output_type
4, // [4:8] is the sub-list for method input_type
11, // 8: ark.v1.AdminService.GetWalletAddress:input_type -> ark.v1.GetWalletAddressRequest
15, // 9: ark.v1.AdminService.GetWalletStatus:input_type -> ark.v1.GetWalletStatusRequest
2, // 10: ark.v1.AdminService.GetBalance:output_type -> ark.v1.GetBalanceResponse
6, // 11: ark.v1.AdminService.GetScheduledSweep:output_type -> ark.v1.GetScheduledSweepResponse
8, // 12: ark.v1.AdminService.GetRoundDetails:output_type -> ark.v1.GetRoundDetailsResponse
10, // 13: ark.v1.AdminService.GetRounds:output_type -> ark.v1.GetRoundsResponse
12, // 14: ark.v1.AdminService.GetWalletAddress:output_type -> ark.v1.GetWalletAddressResponse
16, // 15: ark.v1.AdminService.GetWalletStatus:output_type -> ark.v1.GetWalletStatusResponse
10, // [10:16] is the sub-list for method output_type
4, // [4:10] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
@@ -937,6 +1251,78 @@ func file_ark_v1_admin_proto_init() {
return nil
}
}
file_ark_v1_admin_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetWalletAddressRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_ark_v1_admin_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetWalletAddressResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_ark_v1_admin_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetWalletBalanceRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_ark_v1_admin_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetWalletBalanceResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_ark_v1_admin_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetWalletStatusRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_ark_v1_admin_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetWalletStatusResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -944,7 +1330,7 @@ func file_ark_v1_admin_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_ark_v1_admin_proto_rawDesc,
NumEnums: 0,
NumMessages: 11,
NumMessages: 17,
NumExtensions: 0,
NumServices: 1,
},

View File

@@ -145,6 +145,42 @@ func local_request_AdminService_GetRounds_0(ctx context.Context, marshaler runti
}
func request_AdminService_GetWalletAddress_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetWalletAddressRequest
var metadata runtime.ServerMetadata
msg, err := client.GetWalletAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_AdminService_GetWalletAddress_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetWalletAddressRequest
var metadata runtime.ServerMetadata
msg, err := server.GetWalletAddress(ctx, &protoReq)
return msg, metadata, err
}
func request_AdminService_GetWalletStatus_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetWalletStatusRequest
var metadata runtime.ServerMetadata
msg, err := client.GetWalletStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_AdminService_GetWalletStatus_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetWalletStatusRequest
var metadata runtime.ServerMetadata
msg, err := server.GetWalletStatus(ctx, &protoReq)
return msg, metadata, err
}
// RegisterAdminServiceHandlerServer registers the http handlers for service AdminService to "mux".
// UnaryRPC :call AdminServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@@ -251,6 +287,56 @@ func RegisterAdminServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu
})
mux.Handle("GET", pattern_AdminService_GetWalletAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/ark.v1.AdminService/GetWalletAddress", runtime.WithHTTPPathPattern("/v1/admin/address"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_AdminService_GetWalletAddress_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_AdminService_GetWalletAddress_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_AdminService_GetWalletStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/ark.v1.AdminService/GetWalletStatus", runtime.WithHTTPPathPattern("/v1/admin/status"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_AdminService_GetWalletStatus_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_AdminService_GetWalletStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
@@ -380,6 +466,50 @@ func RegisterAdminServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu
})
mux.Handle("GET", pattern_AdminService_GetWalletAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/ark.v1.AdminService/GetWalletAddress", runtime.WithHTTPPathPattern("/v1/admin/address"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_AdminService_GetWalletAddress_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_AdminService_GetWalletAddress_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_AdminService_GetWalletStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/ark.v1.AdminService/GetWalletStatus", runtime.WithHTTPPathPattern("/v1/admin/status"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_AdminService_GetWalletStatus_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_AdminService_GetWalletStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
@@ -391,6 +521,10 @@ var (
pattern_AdminService_GetRoundDetails_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"v1", "admin", "round", "round_id"}, ""))
pattern_AdminService_GetRounds_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "admin", "rounds"}, ""))
pattern_AdminService_GetWalletAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "admin", "address"}, ""))
pattern_AdminService_GetWalletStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "admin", "status"}, ""))
)
var (
@@ -401,4 +535,8 @@ var (
forward_AdminService_GetRoundDetails_0 = runtime.ForwardResponseMessage
forward_AdminService_GetRounds_0 = runtime.ForwardResponseMessage
forward_AdminService_GetWalletAddress_0 = runtime.ForwardResponseMessage
forward_AdminService_GetWalletStatus_0 = runtime.ForwardResponseMessage
)

View File

@@ -22,6 +22,8 @@ type AdminServiceClient interface {
GetScheduledSweep(ctx context.Context, in *GetScheduledSweepRequest, opts ...grpc.CallOption) (*GetScheduledSweepResponse, error)
GetRoundDetails(ctx context.Context, in *GetRoundDetailsRequest, opts ...grpc.CallOption) (*GetRoundDetailsResponse, error)
GetRounds(ctx context.Context, in *GetRoundsRequest, opts ...grpc.CallOption) (*GetRoundsResponse, error)
GetWalletAddress(ctx context.Context, in *GetWalletAddressRequest, opts ...grpc.CallOption) (*GetWalletAddressResponse, error)
GetWalletStatus(ctx context.Context, in *GetWalletStatusRequest, opts ...grpc.CallOption) (*GetWalletStatusResponse, error)
}
type adminServiceClient struct {
@@ -68,6 +70,24 @@ func (c *adminServiceClient) GetRounds(ctx context.Context, in *GetRoundsRequest
return out, nil
}
func (c *adminServiceClient) GetWalletAddress(ctx context.Context, in *GetWalletAddressRequest, opts ...grpc.CallOption) (*GetWalletAddressResponse, error) {
out := new(GetWalletAddressResponse)
err := c.cc.Invoke(ctx, "/ark.v1.AdminService/GetWalletAddress", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *adminServiceClient) GetWalletStatus(ctx context.Context, in *GetWalletStatusRequest, opts ...grpc.CallOption) (*GetWalletStatusResponse, error) {
out := new(GetWalletStatusResponse)
err := c.cc.Invoke(ctx, "/ark.v1.AdminService/GetWalletStatus", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// AdminServiceServer is the server API for AdminService service.
// All implementations should embed UnimplementedAdminServiceServer
// for forward compatibility
@@ -76,6 +96,8 @@ type AdminServiceServer interface {
GetScheduledSweep(context.Context, *GetScheduledSweepRequest) (*GetScheduledSweepResponse, error)
GetRoundDetails(context.Context, *GetRoundDetailsRequest) (*GetRoundDetailsResponse, error)
GetRounds(context.Context, *GetRoundsRequest) (*GetRoundsResponse, error)
GetWalletAddress(context.Context, *GetWalletAddressRequest) (*GetWalletAddressResponse, error)
GetWalletStatus(context.Context, *GetWalletStatusRequest) (*GetWalletStatusResponse, error)
}
// UnimplementedAdminServiceServer should be embedded to have forward compatible implementations.
@@ -94,6 +116,12 @@ func (UnimplementedAdminServiceServer) GetRoundDetails(context.Context, *GetRoun
func (UnimplementedAdminServiceServer) GetRounds(context.Context, *GetRoundsRequest) (*GetRoundsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetRounds not implemented")
}
func (UnimplementedAdminServiceServer) GetWalletAddress(context.Context, *GetWalletAddressRequest) (*GetWalletAddressResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetWalletAddress not implemented")
}
func (UnimplementedAdminServiceServer) GetWalletStatus(context.Context, *GetWalletStatusRequest) (*GetWalletStatusResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetWalletStatus not implemented")
}
// UnsafeAdminServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to AdminServiceServer will
@@ -178,6 +206,42 @@ func _AdminService_GetRounds_Handler(srv interface{}, ctx context.Context, dec f
return interceptor(ctx, in, info, handler)
}
func _AdminService_GetWalletAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetWalletAddressRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AdminServiceServer).GetWalletAddress(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ark.v1.AdminService/GetWalletAddress",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AdminServiceServer).GetWalletAddress(ctx, req.(*GetWalletAddressRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AdminService_GetWalletStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetWalletStatusRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AdminServiceServer).GetWalletStatus(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ark.v1.AdminService/GetWalletStatus",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AdminServiceServer).GetWalletStatus(ctx, req.(*GetWalletStatusRequest))
}
return interceptor(ctx, in, info, handler)
}
// AdminService_ServiceDesc is the grpc.ServiceDesc for AdminService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -201,6 +265,14 @@ var AdminService_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetRounds",
Handler: _AdminService_GetRounds_Handler,
},
{
MethodName: "GetWalletAddress",
Handler: _AdminService_GetWalletAddress_Handler,
},
{
MethodName: "GetWalletStatus",
Handler: _AdminService_GetWalletStatus_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "ark/v1/admin.proto",

View File

@@ -48,6 +48,9 @@ func main() {
MinRelayFee: cfg.MinRelayFee,
RoundLifetime: cfg.RoundLifetime,
UnilateralExitDelay: cfg.UnilateralExitDelay,
EsploraURL: cfg.EsploraURL,
NeutrinoPeer: cfg.NeutrinoPeer,
WalletPassword: cfg.WalletPassword,
}
svc, err := grpcservice.NewService(svcConfig, appConfig)
if err != nil {
@@ -62,7 +65,7 @@ func main() {
}
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT)
signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, os.Interrupt)
<-sigChan
log.Info("shutting down service...")

View File

@@ -1,11 +1,13 @@
module github.com/ark-network/ark
go 1.21.0
go 1.22.2
replace github.com/ark-network/ark/common => ../common
require (
github.com/ark-network/ark/common v0.0.0
github.com/btcsuite/btcwallet/walletdb v1.4.2
github.com/btcsuite/btcwallet/wtxmgr v1.5.3
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/dgraph-io/badger/v4 v4.2.0
github.com/go-co-op/gocron v1.37.0
@@ -13,45 +15,154 @@ require (
github.com/google/uuid v1.6.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd
github.com/lightningnetwork/lnd v0.18.2-beta
github.com/sirupsen/logrus v1.9.3
github.com/spf13/viper v1.18.2
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
github.com/timshannon/badgerhold/v4 v4.0.3
github.com/vulpemventures/go-elements v0.5.3
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157
github.com/vulpemventures/go-elements v0.5.4
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.34.1
google.golang.org/protobuf v1.34.2
modernc.org/sqlite v1.29.10
)
require github.com/stretchr/objx v0.5.2 // indirect
require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
github.com/aead/siphash v1.0.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.4 // indirect
github.com/btcsuite/btcwallet/wallet/txrules v1.2.1 // indirect
github.com/btcsuite/btcwallet/wallet/txsizes v1.2.4 // indirect
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
github.com/btcsuite/winsvc v1.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/decred/dcrd/lru v1.1.3 // indirect
github.com/docker/cli v20.10.17+incompatible // indirect
github.com/docker/docker v24.0.9+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fergusstrange/embedded-postgres v1.25.0 // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.14.3 // indirect
github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.3 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgtype v1.14.0 // indirect
github.com/jackc/pgx/v4 v4.18.2 // indirect
github.com/jessevdk/go-flags v1.4.0 // indirect
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/jrick/logrotate v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kkdai/bstream v1.0.0 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf // indirect
github.com/lightninglabs/neutrino/cache v1.1.2 // indirect
github.com/lightningnetwork/lightning-onion v1.2.1-0.20230823005744-06182b1d7d2f // indirect
github.com/lightningnetwork/lnd/clock v1.1.1 // indirect
github.com/lightningnetwork/lnd/fn v1.1.0 // indirect
github.com/lightningnetwork/lnd/healthcheck v1.2.4 // indirect
github.com/lightningnetwork/lnd/kvdb v1.4.8 // indirect
github.com/lightningnetwork/lnd/queue v1.1.1 // indirect
github.com/lightningnetwork/lnd/sqldb v1.0.2 // indirect
github.com/lightningnetwork/lnd/ticker v1.1.1 // indirect
github.com/lightningnetwork/lnd/tlv v1.2.6 // indirect
github.com/lightningnetwork/lnd/tor v1.1.2 // indirect
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/miekg/dns v1.1.43 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/runc v1.1.12 // indirect
github.com/ory/dockertest/v3 v3.10.0 // indirect
github.com/prometheus/client_golang v1.11.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.26.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
golang.org/x/tools v0.23.0 // indirect
modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b // indirect
modernc.org/libc v1.50.9 // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
go.etcd.io/etcd/api/v3 v3.5.12 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.12 // indirect
go.etcd.io/etcd/client/v2 v2.305.12 // indirect
go.etcd.io/etcd/client/v3 v3.5.12 // indirect
go.etcd.io/etcd/pkg/v3 v3.5.7 // indirect
go.etcd.io/etcd/raft/v3 v3.5.7 // indirect
go.etcd.io/etcd/server/v3 v3.5.7 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.1 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/sdk v1.0.1 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.opentelemetry.io/proto/otlp v0.9.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.22.0 // indirect
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.49.3 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
require (
github.com/btcsuite/btcd v0.24.2
github.com/btcsuite/btcd/btcec/v2 v2.3.4
github.com/btcsuite/btcd/btcec/v2 v2.3.3
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/btcsuite/btcd/btcutil/psbt v1.1.9
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
github.com/btcsuite/btcwallet v0.16.10-0.20240706055350-e391a1c31df2
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
@@ -64,14 +175,14 @@ require (
github.com/golang/snappy v0.0.4 // indirect
github.com/google/flatbuffers v24.3.25+incompatible // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
@@ -83,13 +194,12 @@ require (
go.opencensus.io v0.24.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240529005216-23cca8864a10 // indirect
golang.org/x/net v0.27.0
golang.org/x/sys v0.22.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/net v0.26.0
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/sqlite v1.29.10
)

View File

@@ -1,17 +1,41 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.110.10 h1:LXy9GEO+timppncPIAZoOj3l58LIU9k+kn48AN7IO3Y=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.112.1 h1:uJSeirPke5UNZHIb4SxfZklVSiWWVqW4oXlETwZziwM=
cloud.google.com/go/compute v1.25.1 h1:ZRpHJedLtTpKgr3RV1Fx23NuaAEN1Zfx9hw1u4aJdjU=
cloud.google.com/go/compute v1.25.1/go.mod h1:oopOIR53ly6viBYxaDhBfJwzUAxf1zE//uf3IB011ls=
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e h1:ahyvB3q25YnZWly5Gq1ekg6jcmWaGj/vG/MhF4aisoc=
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:kGUqhHd//musdITWjFvNTHn90WG9bMLBEPQZ17Cmlpw=
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec h1:1Qb69mGp/UtRPn422BH4/Y4Q3SLUrD9KHuDkm8iodFc=
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec/go.mod h1:CD8UlnlLDiqb36L110uqiP2iSflVjx9g/3U9hCI4q2U=
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY=
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA=
github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=
github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A=
@@ -19,8 +43,8 @@ github.com/btcsuite/btcd v0.24.2 h1:aLmxPguqxza+4ag8R1I2nnJjSu2iFn/kqtHTIImswcY=
github.com/btcsuite/btcd v0.24.2/go.mod h1:5C8ChTkl5ejr3WHj8tkQSCmydiMEPB0ZhQhehpq7Dgg=
github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/btcec/v2 v2.3.3 h1:6+iXlDKE8RMtKsvK0gshlXIuPbyWM/h84Ensb7o3sC0=
github.com/btcsuite/btcd/btcec/v2 v2.3.3/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A=
github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE=
github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdisflzM8=
@@ -34,14 +58,35 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0/go.mod h1:7SFka0XMvUgj3hfZtyd
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/btcwallet v0.16.10-0.20240706055350-e391a1c31df2 h1:mJquwdcEA4hZip4XKbRPAM9rOrus6wlNEcWzMz5CHsI=
github.com/btcsuite/btcwallet v0.16.10-0.20240706055350-e391a1c31df2/go.mod h1:SLFUSQbP8ON/wxholYMfVLvGPJyk7boczOW/ob+nww4=
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.4 h1:poyHFf7+5+RdxNp5r2T6IBRD7RyraUsYARYbp/7t4D8=
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.4/go.mod h1:GETGDQuyq+VFfH1S/+/7slLM/9aNa4l7P4ejX6dJfb0=
github.com/btcsuite/btcwallet/wallet/txrules v1.2.1 h1:UZo7YRzdHbwhK7Rhv3PO9bXgTxiOH45edK5qdsdiatk=
github.com/btcsuite/btcwallet/wallet/txrules v1.2.1/go.mod h1:MVSqRkju/IGxImXYPfBkG65FgEZYA4fXchheILMVl8g=
github.com/btcsuite/btcwallet/wallet/txsizes v1.2.4 h1:nmcKAVTv/cmYrs0A4hbiC6Qw+WTLYy/14SmTt3mLnCo=
github.com/btcsuite/btcwallet/wallet/txsizes v1.2.4/go.mod h1:YqJR8WAAHiKIPesZTr9Cx9Az4fRhRLcJ6GcxzRUZCAc=
github.com/btcsuite/btcwallet/walletdb v1.4.2 h1:zwZZ+zaHo4mK+FAN6KeK85S3oOm+92x2avsHvFAhVBE=
github.com/btcsuite/btcwallet/walletdb v1.4.2/go.mod h1:7ZQ+BvOEre90YT7eSq8bLoxTsgXidUzA/mqbRS114CQ=
github.com/btcsuite/btcwallet/wtxmgr v1.5.3 h1:QrWCio9Leh3DwkWfp+A1SURj8pYn3JuTLv3waP5uEro=
github.com/btcsuite/btcwallet/wtxmgr v1.5.3/go.mod h1:M4nQpxGTXiDlSOODKXboXX7NFthmiBNjzAKKNS7Fhjg=
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw=
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
github.com/btcsuite/golangcrypto v0.0.0-20150304025918-53f62d9b43e8/go.mod h1:tYvUd8KLhm/oXvUeSEs2VlLghFjQt9+ZaF9ghH0JNjc=
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I=
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4=
github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054 h1:uH66TXeswKn5PW5zdZ39xEwfS9an067BirqA+P4QaLI=
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
@@ -51,11 +96,32 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e h1:0XBUw73chJ1VYSsfvcPvVT7auykAJce9FpRr10L6Qhw=
github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:P13beTBKr5Q18lJe1rIoLUqjM+CB1zYrRg44ZqGuQSA=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5 h1:xD/lrqdvwsc+O2bjSSi3YqY73Ke3LAiSCx49aCesA0E=
github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo=
github.com/cockroachdb/errors v1.2.4 h1:Lap807SXTH5tri2TivECb/4abUkMZC9zRoLarvcKDqs=
github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA=
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY=
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg=
github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -68,6 +134,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeC
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
github.com/decred/dcrd/lru v1.1.3 h1:w9EAbvGLyzm6jTjF83UKuqZEiUtJmvRhQDOCEIvSuE0=
github.com/decred/dcrd/lru v1.1.3/go.mod h1:Tw0i0pJyiLEx/oZdHLe1Wdv/Y7EGzAX+sYftnmxBR4o=
github.com/dgraph-io/badger/v4 v4.1.0/go.mod h1:P50u28d39ibBRmIJuQC/NSdBOg46HnHw7al2SW5QRHg=
github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8BzuWsEs=
github.com/dgraph-io/badger/v4 v4.2.0/go.mod h1:qfCqhPoWDFJRx1gp5QwwyGo8xk1lbHUxvK9nK0OGAak=
@@ -75,26 +143,65 @@ github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWa
github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dhui/dktest v0.4.1 h1:/w+IWuDXVymg3IrRJCHHOkMK10m9aNVMOyD0X12YVTg=
github.com/dhui/dktest v0.4.1/go.mod h1:DdOqcUpL7vgyP4GlF3X3w7HbSlz8cEQzwewPveYEQbA=
github.com/docker/cli v20.10.17+incompatible h1:eO2KS7ZFeov5UJeaDmIs1NFEDRf32PaqRpvoEkKBy5M=
github.com/docker/cli v20.10.17+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v24.0.9+incompatible h1:HPGzNmwfLZWdxHqK9/II92pyi1EpYKsAqcl4G0Of9v0=
github.com/docker/docker v24.0.9+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fergusstrange/embedded-postgres v1.25.0 h1:sa+k2Ycrtz40eCRPOzI7Ry7TtkWXXJ+YRsxpKMDhxK0=
github.com/fergusstrange/embedded-postgres v1.25.0/go.mod h1:t/MLs0h9ukYM6FSt99R7InCHs1nW0ordoVCcnzmpTYw=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/getsentry/raven-go v0.2.0 h1:no+xWJRb5ZI7eE8TWgIq1jLulQiIoLG0IfYxv5JYMGs=
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-co-op/gocron v1.37.0 h1:ZYDJGtQ4OMhTLKOKMIch+/CY70Brbb1dGdooLEhh7b0=
github.com/go-co-op/gocron v1.37.0/go.mod h1:3L/n6BkO7ABj+TrfSVXLRzsP26zmikL4ISkLQ0O8iNY=
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs=
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang-migrate/migrate/v4 v4.17.1 h1:4zQ6iqL6t6AiItphxJctQb3cFqWiSpMnX7wLTPnnYO4=
github.com/golang-migrate/migrate/v4 v4.17.1/go.mod h1:m8hinFyWBn0SA4QKHuKh175Pm9wjmxj3S2Mia7dbXzM=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
@@ -119,12 +226,15 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4=
github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA=
github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/flatbuffers v23.5.9+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/flatbuffers v24.3.25+incompatible h1:CX395cjN9Kke9mmalRoL3d81AtFUxJM+yDthflgJGkI=
@@ -137,17 +247,27 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg=
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd h1:gbpYu9NMq8jhDVbvlGkMFWCjLFlqqEZjEmObmhUy6Vo=
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@@ -160,77 +280,250 @@ github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyf
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE=
github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s=
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
github.com/jackc/pgconn v1.14.3 h1:bVoTr12EGANZz66nZPkMInAV/KHD2TxH9npjXXgiB3w=
github.com/jackc/pgconn v1.14.3/go.mod h1:RZbme4uasqzybK2RK5c65VsHxoyaml09lx3tXOcO/VM=
github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438 h1:Dj0L5fhJ9F82ZJyVOmBx6msDp/kfd1t9GRfny/mfJA0=
github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438/go.mod h1:a/s9Lp5W7n/DD0VrVoyJ00FbP2ytTPDVOivvn2bMlds=
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c=
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc=
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.3.3 h1:1HLSx5H+tXR9pW3in3zaztoEwQYRC9SQaYUHjTSUOag=
github.com/jackc/pgproto3/v2 v2.3.3/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
github.com/jackc/pgtype v1.14.0 h1:y+xUdabmyMkJLyApYuPj38mW+aAIqCe5uuBB51rH3Vw=
github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
github.com/jackc/pgx/v4 v4.18.2 h1:xVpYkNR5pk5bMCZGfClbO962UIqVABcAGt7ha1s/FeU=
github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw=
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/kkdai/bstream v1.0.0 h1:Se5gHwgp2VT2uHfDrkbbgbgEvV9cimLELwrPJctSjg8=
github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA=
github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf h1:HZKvJUHlcXI/f/O0Avg7t8sqkPo78HFzjmeYFl6DPnc=
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf/go.mod h1:vxmQPeIQxPf6Jf9rM8R+B4rKBqLA2AjttNxkFBL2Plk=
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd h1:D8aRocHpoCv43hL8egXEMYyPmyOiefFHZ66338KQB2s=
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd/go.mod h1:x3OmY2wsA18+Kc3TSV2QpSUewOCiscw2mKpXgZv2kZk=
github.com/lightninglabs/neutrino/cache v1.1.2 h1:C9DY/DAPaPxbFC+xNNEI/z1SJY9GS3shmlu5hIQ798g=
github.com/lightninglabs/neutrino/cache v1.1.2/go.mod h1:XJNcgdOw1LQnanGjw8Vj44CvguYA25IMKjWFZczwZuo=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20230823005744-06182b1d7d2f h1:Pua7+5TcFEJXIIZ1I2YAUapmbcttmLj4TTi786bIi3s=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20230823005744-06182b1d7d2f/go.mod h1:c0kvRShutpj3l6B9WtTsNTBUtjSmjZXbJd9ZBRQOSKI=
github.com/lightningnetwork/lnd v0.18.2-beta h1:Qv4xQ2ka05vqzmdkFdISHCHP6CzHoYNVKfD18XPjHsM=
github.com/lightningnetwork/lnd v0.18.2-beta/go.mod h1:cGQR1cVEZFZQcCx2VBbDY8xwGjCz+SupSopU1HpjP2I=
github.com/lightningnetwork/lnd/clock v1.1.1 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0=
github.com/lightningnetwork/lnd/clock v1.1.1/go.mod h1:mGnAhPyjYZQJmebS7aevElXKTFDuO+uNFFfMXK1W8xQ=
github.com/lightningnetwork/lnd/fn v1.1.0 h1:W1p/bUXMgAh5YlmawdQYaNgmLaLMT77BilepzWOSZ2A=
github.com/lightningnetwork/lnd/fn v1.1.0/go.mod h1:P027+0CyELd92H9gnReUkGGAqbFA1HwjHWdfaDFD51U=
github.com/lightningnetwork/lnd/healthcheck v1.2.4 h1:lLPLac+p/TllByxGSlkCwkJlkddqMP5UCoawCj3mgFQ=
github.com/lightningnetwork/lnd/healthcheck v1.2.4/go.mod h1:G7Tst2tVvWo7cx6mSBEToQC5L1XOGxzZTPB29g9Rv2I=
github.com/lightningnetwork/lnd/kvdb v1.4.8 h1:xH0a5Vi1yrcZ5BEeF2ba3vlKBRxrL9uYXlWTjOjbNTY=
github.com/lightningnetwork/lnd/kvdb v1.4.8/go.mod h1:J2diNABOoII9UrMnxXS5w7vZwP7CA1CStrl8MnIrb3A=
github.com/lightningnetwork/lnd/queue v1.1.1 h1:99ovBlpM9B0FRCGYJo6RSFDlt8/vOkQQZznVb18iNMI=
github.com/lightningnetwork/lnd/queue v1.1.1/go.mod h1:7A6nC1Qrm32FHuhx/mi1cieAiBZo5O6l8IBIoQxvkz4=
github.com/lightningnetwork/lnd/sqldb v1.0.2 h1:PfuYzScYMD9/QonKo/QvgsbXfTnH5DfldIimkfdW4Bk=
github.com/lightningnetwork/lnd/sqldb v1.0.2/go.mod h1:V2Xl6JNWLTKE97WJnwfs0d0TYJdIQTqK8/3aAwkd3qI=
github.com/lightningnetwork/lnd/ticker v1.1.1 h1:J/b6N2hibFtC7JLV77ULQp++QLtCwT6ijJlbdiZFbSM=
github.com/lightningnetwork/lnd/ticker v1.1.1/go.mod h1:waPTRAAcwtu7Ji3+3k+u/xH5GHovTsCoSVpho0KDvdA=
github.com/lightningnetwork/lnd/tlv v1.2.6 h1:icvQG2yDr6k3ZuZzfRdG3EJp6pHurcuh3R6dg0gv/Mw=
github.com/lightningnetwork/lnd/tlv v1.2.6/go.mod h1:/CmY4VbItpOldksocmGT4lxiJqRP9oLxwSZOda2kzNQ=
github.com/lightningnetwork/lnd/tor v1.1.2 h1:3zv9z/EivNFaMF89v3ciBjCS7kvCj4ZFG7XvD2Qq0/k=
github.com/lightningnetwork/lnd/tor v1.1.2/go.mod h1:j7T9uJ2NLMaHwE7GiBGnpYLn4f7NRoTM6qj+ul6/ycA=
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 h1:sjOGyegMIhvgfq5oaue6Td+hxZuf3tDC8lAPrFldqFw=
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796/go.mod h1:3p7ZTf9V1sNPI5H8P3NkTFF4LuwMdPl2DodF60qAKqY=
github.com/ltcsuite/ltcutil v0.0.0-20181217130922-17f3b04680b6/go.mod h1:8Vg/LTOO0KYa/vlHWJ6XZAevPQThGH5sufO0Hrou/lA=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/dns v1.1.43 h1:JKfpVSCB84vrAmHzyrsxB5NAr5kLoMXZArPSw7Qlgyg=
github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q=
github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM=
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/runc v1.1.12 h1:BOIssBaW1La0/qbNZHXOOa71dZfZEQOzW7dqQf3phss=
github.com/opencontainers/runc v1.1.12/go.mod h1:S+lQwSfncpBha7XTy/5lBwWgm5+y5Ma/O44Ekby9FK8=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/ory/dockertest/v3 v3.10.0 h1:4K3z2VMe8Woe++invjaTB7VRyQXQy5UY+loujO4aNE4=
github.com/ory/dockertest/v3 v3.10.0/go.mod h1:nr57ZbRWMqfsdGdFNLHz5jjNdDb7VVFnzAeW1n5N1Lg=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_golang v1.11.1 h1:+4eQaD7vAZ6DsfsxB15hbE0odUjGI5ARs9yskGu1v4s=
github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ=
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk=
github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js=
github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
@@ -245,10 +538,11 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
@@ -257,6 +551,7 @@ github.com/stretchr/testify v1.1.5-0.20170601210322-f6abca593680/go.mod h1:a8OnR
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
@@ -267,105 +562,212 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/timshannon/badgerhold/v4 v4.0.3 h1:W6pd2qckoXw2cl8eH0ZCV/9CXNaXvaM26tzFi5Tj+v8=
github.com/timshannon/badgerhold/v4 v4.0.3/go.mod h1:IkZIr0kcZLMdD7YJfW/G6epb6ZXHD/h0XR2BTk/VZg8=
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4dN7GR16kFc5fp3d1RIYzJW5onx8Ybykw2YQFA=
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/vulpemventures/fastsha256 v0.0.0-20160815193821-637e65642941 h1:CTcw80hz/Sw8hqlKX5ZYvBUF5gAHSHwdjXxRf/cjDcI=
github.com/vulpemventures/fastsha256 v0.0.0-20160815193821-637e65642941/go.mod h1:GXBJykxW2kUcktGdsgyay7uwwWvkljASfljNcT0mbh8=
github.com/vulpemventures/go-bip32 v0.0.0-20200624192635-867c159da4d7 h1:X7DtNv+YWy76kELMZB/xVkIJ7YNp2vpgMFVsDcQA40U=
github.com/vulpemventures/go-bip32 v0.0.0-20200624192635-867c159da4d7/go.mod h1:Zrvx8XgpWvSPdz1lXnuN083CkoZnzwxBLEB03S8et1I=
github.com/vulpemventures/go-elements v0.5.3 h1:zaC/ynHFwCAzFSOMfzb6BcbD6FXASppSiGMycc95WVA=
github.com/vulpemventures/go-elements v0.5.3/go.mod h1:aBGuWXHaiAIUIcwqCdtEh2iQ3kJjKwHU9ywvhlcRSeU=
github.com/vulpemventures/go-elements v0.5.4 h1:l94xoa9aYPPWiOB7Pmi08rKYvdk/n/sQIbLkQfEAASc=
github.com/vulpemventures/go-elements v0.5.4/go.mod h1:Tvhb+rZWv3lxoI5CdK03J3V+e2QVr/7UAnCYILxFSq4=
github.com/vulpemventures/go-secp256k1-zkp v1.1.6 h1:BmsrmXRLUibwa75Qkk8yELjpzCzlAjYFGLiLiOdq7Xo=
github.com/vulpemventures/go-secp256k1-zkp v1.1.6/go.mod h1:zo7CpgkuPgoe7fAV+inyxsI9IhGmcoFgyD8nqZaPSOM=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ=
go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
go.etcd.io/etcd/api/v3 v3.5.12 h1:W4sw5ZoU2Juc9gBWuLk5U6fHfNVyY1WC5g9uiXZio/c=
go.etcd.io/etcd/api/v3 v3.5.12/go.mod h1:Ot+o0SWSyT6uHhA56al1oCED0JImsRiU9Dc26+C2a+4=
go.etcd.io/etcd/client/pkg/v3 v3.5.12 h1:EYDL6pWwyOsylrQyLp2w+HkQ46ATiOvoEdMarindU2A=
go.etcd.io/etcd/client/pkg/v3 v3.5.12/go.mod h1:seTzl2d9APP8R5Y2hFL3NVlD6qC/dOT+3kvrqPyTas4=
go.etcd.io/etcd/client/v2 v2.305.12 h1:0m4ovXYo1CHaA/Mp3X/Fak5sRNIWf01wk/X1/G3sGKI=
go.etcd.io/etcd/client/v2 v2.305.12/go.mod h1:aQ/yhsxMu+Oht1FOupSr60oBvcS9cKXHrzBpDsPTf9E=
go.etcd.io/etcd/client/v3 v3.5.12 h1:v5lCPXn1pf1Uu3M4laUE2hp/geOTc5uPcYYsNe1lDxg=
go.etcd.io/etcd/client/v3 v3.5.12/go.mod h1:tSbBCakoWmmddL+BKVAJHa9km+O/E+bumDe9mSbPiqw=
go.etcd.io/etcd/pkg/v3 v3.5.7 h1:obOzeVwerFwZ9trMWapU/VjDcYUJb5OfgC1zqEGWO/0=
go.etcd.io/etcd/pkg/v3 v3.5.7/go.mod h1:kcOfWt3Ov9zgYdOiJ/o1Y9zFfLhQjylTgL4Lru8opRo=
go.etcd.io/etcd/raft/v3 v3.5.7 h1:aN79qxLmV3SvIq84aNTliYGmjwsW6NqJSnqmI1HLJKc=
go.etcd.io/etcd/raft/v3 v3.5.7/go.mod h1:TflkAb/8Uy6JFBxcRaH2Fr6Slm9mCPVdI2efzxY96yU=
go.etcd.io/etcd/server/v3 v3.5.7 h1:BTBD8IJUV7YFgsczZMHhMTS67XuA4KpRquL0MFOJGRk=
go.etcd.io/etcd/server/v3 v3.5.7/go.mod h1:gxBgT84issUVBRpZ3XkW1T55NjOb4vZZRI4wVvNhf4A=
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 h1:4Pp6oUg3+e/6M4C0A/3kJ2VYa++dsWVTtGgLVj5xtHg=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0/go.mod h1:Mjt1i1INqiaoZOMGR1RIUJN+i3ChKoFRqzrRQhlkbs0=
go.opentelemetry.io/otel v1.0.1/go.mod h1:OPEOD4jIT2SlZPMmwT6FqZz2C0ZNdQqiWcoK6M0SNFU=
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.1 h1:ofMbch7i29qIUf7VtF+r0HRF6ac0SBaPSziSsKp7wkk=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.1/go.mod h1:Kv8liBeVNFkkkbilbgWRpV+wWuu+H5xdOT6HAgd30iw=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.1 h1:CFMFNoz+CGprjFAFy+RJFrfEe4GBia3RRm2a4fREvCA=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.1/go.mod h1:xOvWoTOrQjxjW61xtOmD/WKGRYb/P4NzRo3bs65U6Rk=
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
go.opentelemetry.io/otel/sdk v1.0.1 h1:wXxFEWGo7XfXupPwVJvTBOaPBC9FEg0wB8hMNrKk+cA=
go.opentelemetry.io/otel/sdk v1.0.1/go.mod h1:HrdXne+BiwsOHYYkBE5ysIcv2bvdZstxzmCQhxTcZkI=
go.opentelemetry.io/otel/trace v1.0.1/go.mod h1:5g4i4fKLaX2BQpSBsxw8YYcgKpMMSW3x7ZTuYBr3sUk=
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.opentelemetry.io/proto/otlp v0.9.0 h1:C0g6TWmQYvjKRnljRULLWUVJGy8Uvu0NEL/5frY2/t4=
go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8=
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
golang.org/x/crypto v0.0.0-20170613210332-850760c427c5/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240529005216-23cca8864a10 h1:vpzMC/iZhYFAjJzHU0Cfuq+w1vLLsF2vLkDrPjzKYck=
golang.org/x/exp v0.0.0-20240529005216-23cca8864a10/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -374,33 +776,49 @@ golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -411,18 +829,25 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y=
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s=
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d h1:Aqf0fiIdUQEj0Gn9mKFFXoQfTTEaNopWpfVyYADxiSg=
google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Od4k8V1LQSizPRUK4OzZ7TBE/20k+jPczUDAEyvn69Y=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d h1:k3zyW3BYYR30e8v3x0bTDdE9vpYFjZHK+HcyqkrppWk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
@@ -436,9 +861,11 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -446,34 +873,45 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=
gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 h1:Izowp2XBH6Ya6rv+hqbceQyw/gSGoXfH/UPoTGduL54=
launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM=
modernc.org/cc/v4 v4.21.2 h1:dycHFB/jDc3IyacKipCNSDrjIC0Lm1hyoWOZTRR20Lk=
modernc.org/cc/v4 v4.21.2/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ=
modernc.org/ccgo/v4 v4.17.8 h1:yyWBf2ipA0Y9GGz/MmCmi3EFpKgeS7ICrAFes+suEbs=
modernc.org/ccgo/v4 v4.17.8/go.mod h1:buJnJ6Fn0tyAdP/dqePbrrvLyr6qslFfTbFrCuaYvtA=
modernc.org/cc/v4 v4.20.0 h1:45Or8mQfbUqJOG9WaxvlFYOAQO0lQ5RvqBcFCXngjxk=
modernc.org/cc/v4 v4.20.0/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ=
modernc.org/ccgo/v4 v4.16.0 h1:ofwORa6vx2FMm0916/CkZjpFPSR70VwTjUCe2Eg5BnA=
modernc.org/ccgo/v4 v4.16.0/go.mod h1:dkNyWIjFrVIZ68DTo36vHK+6/ShBn4ysU61So6PIqCI=
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
modernc.org/gc/v2 v2.4.1 h1:9cNzOqPyMJBvrUipmynX0ZohMhcxPtMccYgGOJdOiBw=
modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU=
modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b h1:BnN1t+pb1cy61zbvSUV7SeI0PwosMhlAEi/vBY4qxp8=
modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4=
modernc.org/libc v1.50.9 h1:hIWf1uz55lorXQhfoEoezdUHjxzuO6ceshET/yWjSjk=
modernc.org/libc v1.50.9/go.mod h1:15P6ublJ9FJR8YQCGy8DeQ2Uwur7iW9Hserr/T3OFZE=
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI=
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4=
modernc.org/libc v1.49.3 h1:j2MRCRdwJI2ls/sGbeSk0t2bypOG/uvPZUsGQFDulqg=
modernc.org/libc v1.49.3/go.mod h1:yMZuGkn7pXbKfoT/M35gFJOAEdSKdxL0q64sF7KqCDo=
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
@@ -488,3 +926,5 @@ modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=

View File

@@ -8,11 +8,12 @@ import (
"github.com/ark-network/ark/internal/core/application"
"github.com/ark-network/ark/internal/core/ports"
"github.com/ark-network/ark/internal/infrastructure/db"
oceanwallet "github.com/ark-network/ark/internal/infrastructure/ocean-wallet"
scheduler "github.com/ark-network/ark/internal/infrastructure/scheduler/gocron"
txbuilder "github.com/ark-network/ark/internal/infrastructure/tx-builder/covenant"
cltxbuilder "github.com/ark-network/ark/internal/infrastructure/tx-builder/covenantless"
btcwallet "github.com/ark-network/ark/internal/infrastructure/wallet/btc-embedded"
liquidwallet "github.com/ark-network/ark/internal/infrastructure/wallet/liquid-standalone"
log "github.com/sirupsen/logrus"
"github.com/vulpemventures/go-elements/network"
)
const minAllowedSequence = 512
@@ -30,9 +31,19 @@ var (
}
supportedTxBuilders = supportedType{
"covenant": {},
"covenantless": {},
}
supportedScanners = supportedType{
"ocean": {},
"btcwallet": {},
}
supportedNetworks = supportedType{
common.Bitcoin.Name: {},
common.BitcoinTestNet.Name: {},
common.BitcoinRegTest.Name: {},
common.Liquid.Name: {},
common.LiquidTestNet.Name: {},
common.LiquidRegTest.Name: {},
}
)
@@ -52,6 +63,10 @@ type Config struct {
RoundLifetime int64
UnilateralExitDelay int64
EsploraURL string
NeutrinoPeer string
WalletPassword string
repo ports.RepoManager
svc application.Service
adminSvc application.AdminService
@@ -80,17 +95,21 @@ func (c *Config) Validate() error {
if c.RoundInterval < 2 {
return fmt.Errorf("invalid round interval, must be at least 2 seconds")
}
if c.Network.Name != common.Liquid.Name &&
c.Network.Name != common.LiquidTestNet.Name &&
c.Network.Name != common.LiquidRegTest.Name {
return fmt.Errorf("invalid network, must be liquid, testnet or regtest")
if !supportedNetworks.supports(c.Network.Name) {
return fmt.Errorf("invalid network, must be one of: %s", supportedNetworks)
}
if len(c.WalletAddr) <= 0 {
return fmt.Errorf("missing onchain wallet address")
}
if common.IsLiquid(c.Network) {
if c.MinRelayFee < 30 {
return fmt.Errorf("invalid min relay fee, must be at least 30 sats")
}
} else {
if c.MinRelayFee < 200 {
return fmt.Errorf("invalid min relay fee, must be at least 200 sats")
}
}
// round life time must be a multiple of 512
if c.RoundLifetime < minAllowedSequence {
return fmt.Errorf(
@@ -191,7 +210,31 @@ func (c *Config) repoManager() error {
}
func (c *Config) walletService() error {
svc, err := oceanwallet.NewService(c.WalletAddr)
if common.IsLiquid(c.Network) {
svc, err := liquidwallet.NewService(c.WalletAddr)
if err != nil {
return err
}
c.wallet = svc
return nil
}
if len(c.EsploraURL) == 0 {
return fmt.Errorf("missing esplora url, covenant-less ark requires ARK_ESPLORA_URL to be set")
}
if len(c.WalletPassword) == 0 {
return fmt.Errorf("missing wallet password, covenant-less ark requires ARK_WALLET_PASSWORD to be set")
}
svc, err := btcwallet.NewService(btcwallet.WalletConfig{
Datadir: c.DbDir,
Password: []byte(c.WalletPassword),
Network: c.Network,
EsploraURL: c.EsploraURL,
},
btcwallet.WithNeutrino(c.NeutrinoPeer),
)
if err != nil {
return err
}
@@ -203,12 +246,14 @@ func (c *Config) walletService() error {
func (c *Config) txBuilderService() error {
var svc ports.TxBuilder
var err error
net := c.mainChain()
switch c.TxBuilderType {
case "covenant":
svc = txbuilder.NewTxBuilder(
c.wallet, net, c.RoundLifetime, c.UnilateralExitDelay,
c.wallet, c.Network, c.RoundLifetime, c.UnilateralExitDelay,
)
case "covenantless":
svc = cltxbuilder.NewTxBuilder(
c.wallet, c.Network, c.RoundLifetime, c.UnilateralExitDelay,
)
default:
err = fmt.Errorf("unknown tx builder type")
@@ -223,15 +268,9 @@ func (c *Config) txBuilderService() error {
func (c *Config) scannerService() error {
var svc ports.BlockchainScanner
var err error
switch c.BlockchainScannerType {
case "ocean":
svc = c.wallet
default:
err = fmt.Errorf("unknown blockchain scanner type")
}
if err != nil {
return err
svc = c.wallet
}
c.scanner = svc
@@ -256,11 +295,22 @@ func (c *Config) schedulerService() error {
}
func (c *Config) appService() error {
net := c.mainChain()
svc, err := application.NewService(
c.Network, net,
c.RoundInterval, c.RoundLifetime, c.UnilateralExitDelay, c.MinRelayFee,
c.wallet, c.repo, c.txBuilder, c.scanner, c.scheduler,
if common.IsLiquid(c.Network) {
svc, err := application.NewCovenantService(
c.Network, c.RoundInterval, c.RoundLifetime, c.UnilateralExitDelay,
c.MinRelayFee, c.wallet, c.repo, c.txBuilder, c.scanner, c.scheduler,
)
if err != nil {
return err
}
c.svc = svc
return nil
}
svc, err := application.NewCovenantlessService(
c.Network, c.RoundInterval, c.RoundLifetime, c.UnilateralExitDelay,
c.MinRelayFee, c.wallet, c.repo, c.txBuilder, c.scanner, c.scheduler,
)
if err != nil {
return err
@@ -275,17 +325,6 @@ func (c *Config) adminService() error {
return nil
}
func (c *Config) mainChain() network.Network {
switch c.Network.Name {
case common.LiquidTestNet.Name:
return network.Testnet
case common.LiquidRegTest.Name:
return network.Regtest
default:
return network.Liquid
}
}
type supportedType map[string]struct{}
func (t supportedType) String() string {

View File

@@ -29,6 +29,9 @@ type Config struct {
UnilateralExitDelay int64
AuthUser string
AuthPass string
EsploraURL string
NeutrinoPeer string
WalletPassword string
}
var (
@@ -50,6 +53,9 @@ var (
UnilateralExitDelay = "UNILATERAL_EXIT_DELAY"
AuthUser = "AUTH_USER"
AuthPass = "AUTH_PASS"
EsploraURL = "ESPLORA_URL"
NeutrinoPeer = "NEUTRINO_PEER"
WalletPassword = "WALLET_PASSWORD"
defaultDatadir = common.AppDataDir("arkd", false)
defaultRoundInterval = 5
@@ -122,6 +128,9 @@ func LoadConfig() (*Config, error) {
UnilateralExitDelay: viper.GetInt64(UnilateralExitDelay),
AuthUser: viper.GetString(AuthUser),
AuthPass: viper.GetString(AuthPass),
EsploraURL: viper.GetString(EsploraURL),
NeutrinoPeer: viper.GetString(NeutrinoPeer),
WalletPassword: viper.GetString(WalletPassword),
}, nil
}
@@ -145,6 +154,12 @@ func getNetwork() (common.Network, error) {
return common.LiquidTestNet, nil
case common.LiquidRegTest.Name:
return common.LiquidRegTest, nil
case common.Bitcoin.Name:
return common.Bitcoin, nil
case common.BitcoinTestNet.Name:
return common.BitcoinTestNet, nil
case common.BitcoinRegTest.Name:
return common.BitcoinRegTest, nil
default:
return common.Network{}, fmt.Errorf("unknown network %s", viper.GetString(Network))
}

View File

@@ -45,6 +45,8 @@ type AdminService interface {
GetScheduledSweeps(ctx context.Context) ([]ScheduledSweep, error)
GetRoundDetails(ctx context.Context, roundId string) (*RoundDetails, error)
GetRounds(ctx context.Context, after int64, before int64) ([]string, error)
GetWalletAddress(ctx context.Context) (string, error)
GetWalletStatus(ctx context.Context) (*WalletStatus, error)
}
type adminService struct {
@@ -167,3 +169,24 @@ func (a *adminService) GetScheduledSweeps(ctx context.Context) ([]ScheduledSweep
return scheduledSweeps, nil
}
func (a *adminService) GetWalletAddress(ctx context.Context) (string, error) {
addresses, err := a.walletSvc.DeriveAddresses(ctx, 1)
if err != nil {
return "", err
}
return addresses[0], nil
}
func (a *adminService) GetWalletStatus(ctx context.Context) (*WalletStatus, error) {
status, err := a.walletSvc.Status(ctx)
if err != nil {
return nil, err
}
return &WalletStatus{
IsInitialized: status.IsInitialized(),
IsUnlocked: status.IsUnlocked(),
IsSynced: status.IsSynced(),
}, nil
}

View File

@@ -5,6 +5,7 @@ import (
"context"
"encoding/hex"
"fmt"
"strings"
"sync"
"time"
@@ -12,6 +13,7 @@ import (
"github.com/ark-network/ark/common/tree"
"github.com/ark-network/ark/internal/core/domain"
"github.com/ark-network/ark/internal/core/ports"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
log "github.com/sirupsen/logrus"
@@ -20,46 +22,8 @@ import (
"github.com/vulpemventures/go-elements/psetv2"
)
var (
paymentsThreshold = int64(128)
dustAmount = uint64(450)
)
type ServiceInfo struct {
PubKey string
RoundLifetime int64
UnilateralExitDelay int64
RoundInterval int64
Network string
MinRelayFee int64
}
type Service interface {
Start() error
Stop()
SpendVtxos(ctx context.Context, inputs []domain.VtxoKey) (string, error)
ClaimVtxos(ctx context.Context, creds string, receivers []domain.Receiver) error
SignVtxos(ctx context.Context, forfeitTxs []string) error
GetRoundByTxid(ctx context.Context, poolTxid string) (*domain.Round, error)
GetRoundById(ctx context.Context, id string) (*domain.Round, error)
GetCurrentRound(ctx context.Context) (*domain.Round, error)
GetEventsChannel(ctx context.Context) <-chan domain.RoundEvent
UpdatePaymentStatus(ctx context.Context, id string) (unsignedForfeitTxs []string, round *domain.Round, err error)
ListVtxos(ctx context.Context, pubkey *secp256k1.PublicKey) ([]domain.Vtxo, []domain.Vtxo, error)
GetInfo(ctx context.Context) (*ServiceInfo, error)
Onboard(ctx context.Context, boardingTx string, congestionTree tree.CongestionTree, userPubkey *secp256k1.PublicKey) error
TrustedOnboarding(ctx context.Context, userPubKey *secp256k1.PublicKey) (string, error)
}
type onboarding struct {
tx string
congestionTree tree.CongestionTree
userPubkey *secp256k1.PublicKey
}
type service struct {
type covenantService struct {
network common.Network
onchainNework network.Network
pubkey *secp256k1.PublicKey
roundLifetime int64
roundInterval int64
@@ -83,8 +47,8 @@ type service struct {
currentRound *domain.Round
}
func NewService(
network common.Network, onchainNetwork network.Network,
func NewCovenantService(
network common.Network,
roundInterval, roundLifetime, unilateralExitDelay int64, minRelayFee uint64,
walletSvc ports.WalletService, repoManager ports.RepoManager,
builder ports.TxBuilder, scanner ports.BlockchainScanner,
@@ -94,8 +58,7 @@ func NewService(
onboardingCh := make(chan onboarding)
paymentRequests := newPaymentsMap(nil)
genesisHash, _ := chainhash.NewHashFromStr(onchainNetwork.GenesisBlockHash)
forfeitTxs := newForfeitTxsMap(genesisHash)
forfeitTxs := newForfeitTxsMap(builder)
pubkey, err := walletSvc.GetPubkey(context.Background())
if err != nil {
return nil, fmt.Errorf("failed to fetch pubkey: %s", err)
@@ -103,8 +66,8 @@ func NewService(
sweeper := newSweeper(walletSvc, repoManager, builder, scheduler)
svc := &service{
network, onchainNetwork, pubkey,
svc := &covenantService{
network, pubkey,
roundLifetime, roundInterval, unilateralExitDelay, minRelayFee,
walletSvc, repoManager, builder, scanner, sweeper,
paymentRequests, forfeitTxs, eventsCh, onboardingCh,
@@ -129,7 +92,7 @@ func NewService(
return svc, nil
}
func (s *service) Start() error {
func (s *covenantService) Start() error {
log.Debug("starting sweeper service")
if err := s.sweeper.start(); err != nil {
return err
@@ -140,7 +103,7 @@ func (s *service) Start() error {
return nil
}
func (s *service) Stop() {
func (s *covenantService) Stop() {
s.sweeper.stop()
// nolint
vtxos, _ := s.repoManager.Vtxos().GetAllSweepableVtxos(context.Background())
@@ -156,7 +119,7 @@ func (s *service) Stop() {
close(s.onboardingCh)
}
func (s *service) SpendVtxos(ctx context.Context, inputs []domain.VtxoKey) (string, error) {
func (s *covenantService) SpendVtxos(ctx context.Context, inputs []domain.VtxoKey) (string, error) {
vtxos, err := s.repoManager.Vtxos().GetVtxos(ctx, inputs)
if err != nil {
return "", err
@@ -177,7 +140,7 @@ func (s *service) SpendVtxos(ctx context.Context, inputs []domain.VtxoKey) (stri
return payment.Id, nil
}
func (s *service) ClaimVtxos(ctx context.Context, creds string, receivers []domain.Receiver) error {
func (s *covenantService) ClaimVtxos(ctx context.Context, creds string, receivers []domain.Receiver) error {
// Check credentials
payment, ok := s.paymentRequests.view(creds)
if !ok {
@@ -190,7 +153,7 @@ func (s *service) ClaimVtxos(ctx context.Context, creds string, receivers []doma
return s.paymentRequests.update(*payment)
}
func (s *service) UpdatePaymentStatus(_ context.Context, id string) ([]string, *domain.Round, error) {
func (s *covenantService) UpdatePaymentStatus(_ context.Context, id string) ([]string, *domain.Round, error) {
err := s.paymentRequests.updatePingTimestamp(id)
if err != nil {
if _, ok := err.(errPaymentNotFound); ok {
@@ -203,32 +166,32 @@ func (s *service) UpdatePaymentStatus(_ context.Context, id string) ([]string, *
return nil, nil, nil
}
func (s *service) SignVtxos(ctx context.Context, forfeitTxs []string) error {
func (s *covenantService) SignVtxos(ctx context.Context, forfeitTxs []string) error {
return s.forfeitTxs.sign(forfeitTxs)
}
func (s *service) ListVtxos(ctx context.Context, pubkey *secp256k1.PublicKey) ([]domain.Vtxo, []domain.Vtxo, error) {
func (s *covenantService) ListVtxos(ctx context.Context, pubkey *secp256k1.PublicKey) ([]domain.Vtxo, []domain.Vtxo, error) {
pk := hex.EncodeToString(pubkey.SerializeCompressed())
return s.repoManager.Vtxos().GetAllVtxos(ctx, pk)
}
func (s *service) GetEventsChannel(ctx context.Context) <-chan domain.RoundEvent {
func (s *covenantService) GetEventsChannel(ctx context.Context) <-chan domain.RoundEvent {
return s.eventsCh
}
func (s *service) GetRoundByTxid(ctx context.Context, poolTxid string) (*domain.Round, error) {
func (s *covenantService) GetRoundByTxid(ctx context.Context, poolTxid string) (*domain.Round, error) {
return s.repoManager.Rounds().GetRoundWithTxid(ctx, poolTxid)
}
func (s *service) GetCurrentRound(ctx context.Context) (*domain.Round, error) {
func (s *covenantService) GetCurrentRound(ctx context.Context) (*domain.Round, error) {
return domain.NewRoundFromEvents(s.currentRound.Events()), nil
}
func (s *service) GetRoundById(ctx context.Context, id string) (*domain.Round, error) {
func (s *covenantService) GetRoundById(ctx context.Context, id string) (*domain.Round, error) {
return s.repoManager.Rounds().GetRoundWithId(ctx, id)
}
func (s *service) GetInfo(ctx context.Context) (*ServiceInfo, error) {
func (s *covenantService) GetInfo(ctx context.Context) (*ServiceInfo, error) {
pubkey := hex.EncodeToString(s.pubkey.SerializeCompressed())
return &ServiceInfo{
@@ -241,7 +204,7 @@ func (s *service) GetInfo(ctx context.Context) (*ServiceInfo, error) {
}, nil
}
func (s *service) Onboard(
func (s *covenantService) Onboard(
ctx context.Context, boardingTx string,
congestionTree tree.CongestionTree, userPubkey *secp256k1.PublicKey,
) error {
@@ -285,7 +248,7 @@ func (s *service) Onboard(
return nil
}
func (s *service) TrustedOnboarding(
func (s *covenantService) TrustedOnboarding(
ctx context.Context, userPubKey *secp256k1.PublicKey,
) (string, error) {
congestionTreeLeaf := tree.Receiver{
@@ -293,14 +256,14 @@ func (s *service) TrustedOnboarding(
}
_, sharedOutputScript, _, err := tree.CraftCongestionTree(
s.onchainNework.AssetID, s.pubkey, []tree.Receiver{congestionTreeLeaf},
s.onchainNework().AssetID, s.pubkey, []tree.Receiver{congestionTreeLeaf},
s.minRelayFee, s.roundLifetime, s.unilateralExitDelay,
)
if err != nil {
return "", err
}
pay, err := payment.FromScript(sharedOutputScript, &s.onchainNework, nil)
pay, err := payment.FromScript(sharedOutputScript, s.onchainNework(), nil)
if err != nil {
return "", err
}
@@ -324,11 +287,11 @@ func (s *service) TrustedOnboarding(
return address, nil
}
func (s *service) start() {
func (s *covenantService) start() {
s.startRound()
}
func (s *service) startRound() {
func (s *covenantService) startRound() {
round := domain.NewRound(dustAmount)
//nolint:all
round.StartRegistration()
@@ -342,7 +305,7 @@ func (s *service) startRound() {
log.Debugf("started registration stage for new round: %s", round.Id)
}
func (s *service) startFinalization() {
func (s *covenantService) startFinalization() {
ctx := context.Background()
round := s.currentRound
@@ -427,7 +390,7 @@ func (s *service) startFinalization() {
log.Debugf("started finalization stage for round: %s", round.Id)
}
func (s *service) finalizeRound() {
func (s *covenantService) finalizeRound() {
defer s.startRound()
ctx := context.Background()
@@ -453,7 +416,7 @@ func (s *service) finalizeRound() {
}
log.Debugf("signing round transaction %s\n", round.Id)
signedPoolTx, err := s.wallet.SignPset(ctx, round.UnsignedTx, true)
signedPoolTx, err := s.wallet.SignTransaction(ctx, round.UnsignedTx, true)
if err != nil {
changes = round.Fail(fmt.Errorf("failed to sign round tx: %s", err))
log.WithError(err).Warn("failed to sign round tx")
@@ -472,13 +435,13 @@ func (s *service) finalizeRound() {
log.Debugf("finalized round %s with pool tx %s", round.Id, round.Txid)
}
func (s *service) listenToOnboarding() {
func (s *covenantService) listenToOnboarding() {
for onboarding := range s.onboardingCh {
go s.handleOnboarding(onboarding)
}
}
func (s *service) handleOnboarding(onboarding onboarding) {
func (s *covenantService) handleOnboarding(onboarding onboarding) {
ctx := context.Background()
ptx, _ := psetv2.NewPsetFromBase64(onboarding.tx)
@@ -510,7 +473,7 @@ func (s *service) handleOnboarding(onboarding onboarding) {
}
pubkey := hex.EncodeToString(onboarding.userPubkey.SerializeCompressed())
payments := getPaymentsFromOnboarding(onboarding.congestionTree, pubkey)
payments := getPaymentsFromOnboardingLiquid(onboarding.congestionTree, pubkey)
round := domain.NewFinalizedRound(
dustAmount, pubkey, txid, onboarding.tx, onboarding.congestionTree, payments,
)
@@ -520,7 +483,7 @@ func (s *service) handleOnboarding(onboarding onboarding) {
}
}
func (s *service) listenToScannerNotifications() {
func (s *covenantService) listenToScannerNotifications() {
ctx := context.Background()
chVtxos := s.scanner.GetNotificationChannel(ctx)
@@ -539,7 +502,7 @@ func (s *service) listenToScannerNotifications() {
}
treeFactoryFn, sharedOutputScript, sharedOutputAmount, err := tree.CraftCongestionTree(
s.onchainNework.AssetID, s.pubkey, []tree.Receiver{congestionTreeLeaf},
s.onchainNework().AssetID, s.pubkey, []tree.Receiver{congestionTreeLeaf},
s.minRelayFee, s.roundLifetime, s.unilateralExitDelay,
)
if err != nil {
@@ -571,7 +534,7 @@ func (s *service) listenToScannerNotifications() {
}
pubkey := hex.EncodeToString(userPubkey.SerializeCompressed())
payments := getPaymentsFromOnboarding(congestionTree, pubkey)
payments := getPaymentsFromOnboardingLiquid(congestionTree, pubkey)
round := domain.NewFinalizedRound(
dustAmount, pubkey, v.Txid, "", congestionTree, payments,
)
@@ -623,7 +586,7 @@ func (s *service) listenToScannerNotifications() {
continue
}
forfeitTx, err := findForfeitTx(round.ForfeitTxs, connectorTxid, connectorVout, vtxo.Txid)
forfeitTx, err := findForfeitTxLiquid(round.ForfeitTxs, connectorTxid, connectorVout, vtxo.Txid)
if err != nil {
log.WithError(err).Warn("failed to retrieve forfeit tx")
continue
@@ -634,19 +597,19 @@ func (s *service) listenToScannerNotifications() {
continue
}
signedForfeitTx, err := s.wallet.SignPset(ctx, forfeitTx, false)
signedForfeitTx, err := s.wallet.SignTransaction(ctx, forfeitTx, false)
if err != nil {
log.WithError(err).Warn("failed to sign connector input in forfeit tx")
continue
}
signedForfeitTx, err = s.wallet.SignPsetWithKey(ctx, signedForfeitTx, []int{1})
signedForfeitTx, err = s.wallet.SignTransactionTapscript(ctx, signedForfeitTx, []int{1})
if err != nil {
log.WithError(err).Warn("failed to sign vtxo input in forfeit tx")
continue
}
forfeitTxHex, err := finalizeAndExtractForfeit(signedForfeitTx)
forfeitTxHex, err := s.builder.FinalizeAndExtractForfeit(signedForfeitTx)
if err != nil {
log.WithError(err).Warn("failed to finalize forfeit tx")
continue
@@ -664,7 +627,7 @@ func (s *service) listenToScannerNotifications() {
}
}
func (s *service) getNextConnector(
func (s *covenantService) getNextConnector(
ctx context.Context,
round domain.Round,
) (string, uint32, error) {
@@ -705,21 +668,21 @@ func (s *service) getNextConnector(
for _, u := range utxos {
if u.GetValue() > 450 {
for _, b64 := range round.Connectors {
pset, err := psetv2.NewPsetFromBase64(b64)
partial, err := psbt.NewFromRawBytes(strings.NewReader(b64), true)
if err != nil {
return "", 0, err
}
for _, i := range pset.Inputs {
if chainhash.Hash(i.PreviousTxid).String() == u.GetTxid() && i.PreviousTxIndex == u.GetIndex() {
connectorOutpoint := newOutpointFromPsetInput(pset.Inputs[0])
for _, i := range partial.UnsignedTx.TxIn {
if i.PreviousOutPoint.Hash.String() == u.GetTxid() && i.PreviousOutPoint.Index == u.GetIndex() {
connectorOutpoint := txOutpoint{u.GetTxid(), u.GetIndex()}
if err := s.wallet.LockConnectorUtxos(ctx, []ports.TxOutpoint{connectorOutpoint}); err != nil {
return "", 0, err
}
// sign & broadcast the connector tx
signedConnectorTx, err := s.wallet.SignPset(ctx, b64, true)
signedConnectorTx, err := s.wallet.SignTransaction(ctx, b64, true)
if err != nil {
return "", 0, err
}
@@ -745,7 +708,7 @@ func (s *service) getNextConnector(
return "", 0, fmt.Errorf("no connector utxos found")
}
func (s *service) updateVtxoSet(round *domain.Round) {
func (s *covenantService) updateVtxoSet(round *domain.Round) {
// Update the vtxo set only after a round is finalized.
if !round.IsEnded() {
return
@@ -793,7 +756,7 @@ func (s *service) updateVtxoSet(round *domain.Round) {
}
}
func (s *service) propagateEvents(round *domain.Round) {
func (s *covenantService) propagateEvents(round *domain.Round) {
lastEvent := round.Events()[len(round.Events())-1]
switch e := lastEvent.(type) {
case domain.RoundFinalizationStarted:
@@ -810,7 +773,7 @@ func (s *service) propagateEvents(round *domain.Round) {
}
}
func (s *service) scheduleSweepVtxosForRound(round *domain.Round) {
func (s *covenantService) scheduleSweepVtxosForRound(round *domain.Round) {
// Schedule the sweeping procedure only for completed round.
if !round.IsEnded() {
return
@@ -827,7 +790,7 @@ func (s *service) scheduleSweepVtxosForRound(round *domain.Round) {
}
}
func (s *service) getNewVtxos(round *domain.Round) []domain.Vtxo {
func (s *covenantService) getNewVtxos(round *domain.Round) []domain.Vtxo {
if len(round.CongestionTree) <= 0 {
return nil
}
@@ -868,7 +831,7 @@ func (s *service) getNewVtxos(round *domain.Round) []domain.Vtxo {
return vtxos
}
func (s *service) startWatchingVtxos(vtxos []domain.Vtxo) error {
func (s *covenantService) startWatchingVtxos(vtxos []domain.Vtxo) error {
scripts, err := s.extractVtxosScripts(vtxos)
if err != nil {
return err
@@ -877,7 +840,7 @@ func (s *service) startWatchingVtxos(vtxos []domain.Vtxo) error {
return s.scanner.WatchScripts(context.Background(), scripts)
}
func (s *service) stopWatchingVtxos(vtxos []domain.Vtxo) {
func (s *covenantService) stopWatchingVtxos(vtxos []domain.Vtxo) {
scripts, err := s.extractVtxosScripts(vtxos)
if err != nil {
log.WithError(err).Warn("failed to extract scripts from vtxos")
@@ -895,7 +858,7 @@ func (s *service) stopWatchingVtxos(vtxos []domain.Vtxo) {
}
}
func (s *service) restoreWatchingVtxos() error {
func (s *covenantService) restoreWatchingVtxos() error {
sweepableRounds, err := s.repoManager.Rounds().GetSweepableRounds(context.Background())
if err != nil {
return err
@@ -930,7 +893,7 @@ func (s *service) restoreWatchingVtxos() error {
return nil
}
func (s *service) extractVtxosScripts(vtxos []domain.Vtxo) ([]string, error) {
func (s *covenantService) extractVtxosScripts(vtxos []domain.Vtxo) ([]string, error) {
indexedScripts := make(map[string]struct{})
for _, vtxo := range vtxos {
buf, err := hex.DecodeString(vtxo.Pubkey)
@@ -955,7 +918,7 @@ func (s *service) extractVtxosScripts(vtxos []domain.Vtxo) ([]string, error) {
return scripts, nil
}
func (s *service) saveEvents(
func (s *covenantService) saveEvents(
ctx context.Context, id string, events []domain.RoundEvent,
) error {
if len(events) <= 0 {
@@ -968,17 +931,20 @@ func (s *service) saveEvents(
return s.repoManager.Rounds().AddOrUpdateRound(ctx, *round)
}
func getSpentVtxos(payments map[string]domain.Payment) []domain.VtxoKey {
vtxos := make([]domain.VtxoKey, 0)
for _, p := range payments {
for _, vtxo := range p.Inputs {
vtxos = append(vtxos, vtxo.VtxoKey)
func (s *covenantService) onchainNework() *network.Network {
switch s.network.Name {
case common.Liquid.Name:
return &network.Liquid
case common.LiquidRegTest.Name:
return &network.Regtest
case common.LiquidTestNet.Name:
return &network.Testnet
default:
return &network.Liquid
}
}
return vtxos
}
func getPaymentsFromOnboarding(
func getPaymentsFromOnboardingLiquid(
congestionTree tree.CongestionTree, userKey string,
) []domain.Payment {
leaves := congestionTree.Leaves()
@@ -995,27 +961,7 @@ func getPaymentsFromOnboarding(
return []domain.Payment{*payment}
}
func finalizeAndExtractForfeit(b64 string) (string, error) {
p, err := psetv2.NewPsetFromBase64(b64)
if err != nil {
return "", err
}
// finalize connector input
if err := psetv2.FinalizeAll(p); err != nil {
return "", err
}
// extract the forfeit tx
extracted, err := psetv2.Extract(p)
if err != nil {
return "", err
}
return extracted.ToHex()
}
func findForfeitTx(
func findForfeitTxLiquid(
forfeits []string, connectorTxid string, connectorVout uint32, vtxoTxid string,
) (string, error) {
for _, forfeit := range forfeits {
@@ -1036,23 +982,3 @@ func findForfeitTx(
return "", fmt.Errorf("forfeit tx not found")
}
type txOutpoint struct {
txid string
vout uint32
}
func newOutpointFromPsetInput(input psetv2.Input) txOutpoint {
return txOutpoint{
txid: chainhash.Hash(input.PreviousTxid).String(),
vout: input.PreviousTxIndex,
}
}
func (outpoint txOutpoint) GetTxid() string {
return outpoint.txid
}
func (outpoint txOutpoint) GetIndex() uint32 {
return outpoint.vout
}

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,6 @@ package application
import (
"context"
"fmt"
"strings"
"time"
"github.com/ark-network/ark/common/tree"
@@ -150,6 +149,7 @@ func (s *sweeper) createTask(
for _, input := range inputs {
// sweepableVtxos related to the sweep input
sweepableVtxos := make([]domain.VtxoKey, 0)
fmt.Println("input", input.GetHash().String(), input.GetIndex())
// check if input is the vtxo itself
vtxos, _ := s.repoManager.Vtxos().GetVtxos(
@@ -167,7 +167,7 @@ func (s *sweeper) createTask(
}
} else {
// if it's not a vtxo, find all the vtxos leaves reachable from that input
vtxosLeaves, err := congestionTree.FindLeaves(input.GetHash().String(), input.GetIndex())
vtxosLeaves, err := s.builder.FindLeaves(congestionTree, input.GetHash().String(), input.GetIndex())
if err != nil {
log.WithError(err).Error("error while finding vtxos leaves")
continue
@@ -220,7 +220,7 @@ func (s *sweeper) createTask(
err = nil
txid := ""
// retry until the tx is broadcasted or the error is not BIP68 final
for len(txid) == 0 && (err == nil || strings.Contains(err.Error(), "non-BIP68-final")) {
for len(txid) == 0 && (err == nil || err == ports.ErrNonFinalBIP68) {
if err != nil {
log.Debugln("sweep tx not BIP68 final, retrying in 5 seconds")
time.Sleep(5 * time.Second)

View File

@@ -0,0 +1,72 @@
package application
import (
"context"
"github.com/ark-network/ark/common/tree"
"github.com/ark-network/ark/internal/core/domain"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
)
var (
paymentsThreshold = int64(128)
dustAmount = uint64(450)
)
type Service interface {
Start() error
Stop()
SpendVtxos(ctx context.Context, inputs []domain.VtxoKey) (string, error)
ClaimVtxos(ctx context.Context, creds string, receivers []domain.Receiver) error
SignVtxos(ctx context.Context, forfeitTxs []string) error
GetRoundByTxid(ctx context.Context, poolTxid string) (*domain.Round, error)
GetRoundById(ctx context.Context, id string) (*domain.Round, error)
GetCurrentRound(ctx context.Context) (*domain.Round, error)
GetEventsChannel(ctx context.Context) <-chan domain.RoundEvent
UpdatePaymentStatus(
ctx context.Context, paymentId string,
) (unsignedForfeitTxs []string, currentRound *domain.Round, err error)
ListVtxos(
ctx context.Context, pubkey *secp256k1.PublicKey,
) (spendableVtxos, spentVtxos []domain.Vtxo, err error)
GetInfo(ctx context.Context) (*ServiceInfo, error)
Onboard(
ctx context.Context, boardingTx string,
congestionTree tree.CongestionTree, userPubkey *secp256k1.PublicKey,
) error
TrustedOnboarding(ctx context.Context, userPubKey *secp256k1.PublicKey) (string, error)
}
type ServiceInfo struct {
PubKey string
RoundLifetime int64
UnilateralExitDelay int64
RoundInterval int64
Network string
MinRelayFee int64
}
type WalletStatus struct {
IsInitialized bool
IsUnlocked bool
IsSynced bool
}
type onboarding struct {
tx string
congestionTree tree.CongestionTree
userPubkey *secp256k1.PublicKey
}
type txOutpoint struct {
txid string
vout uint32
}
func (outpoint txOutpoint) GetTxid() string {
return outpoint.txid
}
func (outpoint txOutpoint) GetIndex() uint32 {
return outpoint.vout
}

View File

@@ -7,13 +7,10 @@ import (
"sync"
"time"
"github.com/ark-network/ark/common"
"github.com/ark-network/ark/common/tree"
"github.com/ark-network/ark/internal/core/domain"
"github.com/ark-network/ark/internal/core/ports"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/vulpemventures/go-elements/psetv2"
"github.com/sirupsen/logrus"
)
type timedPayment struct {
@@ -144,11 +141,11 @@ type signedTx struct {
type forfeitTxsMap struct {
lock *sync.RWMutex
forfeitTxs map[string]*signedTx
genesisBlockHash *chainhash.Hash
builder ports.TxBuilder
}
func newForfeitTxsMap(genesisBlockHash *chainhash.Hash) *forfeitTxsMap {
return &forfeitTxsMap{&sync.RWMutex{}, make(map[string]*signedTx), genesisBlockHash}
func newForfeitTxsMap(txBuilder ports.TxBuilder) *forfeitTxsMap {
return &forfeitTxsMap{&sync.RWMutex{}, make(map[string]*signedTx), txBuilder}
}
func (m *forfeitTxsMap) push(txs []string) {
@@ -156,11 +153,7 @@ func (m *forfeitTxsMap) push(txs []string) {
defer m.lock.Unlock()
for _, tx := range txs {
ptx, _ := psetv2.NewPsetFromBase64(tx)
utx, _ := ptx.UnsignedTx()
txid := utx.TxHash().String()
signed := false
signed, txid, _ := m.builder.VerifyForfeitTx(tx)
m.forfeitTxs[txid] = &signedTx{tx, signed}
}
}
@@ -170,47 +163,17 @@ func (m *forfeitTxsMap) sign(txs []string) error {
defer m.lock.Unlock()
for _, tx := range txs {
ptx, _ := psetv2.NewPsetFromBase64(tx)
utx, _ := ptx.UnsignedTx()
txid := utx.TxHash().String()
valid, txid, err := m.builder.VerifyForfeitTx(tx)
if err != nil {
return err
}
if _, ok := m.forfeitTxs[txid]; ok {
for index, input := range ptx.Inputs {
if len(input.TapScriptSig) > 0 {
for _, tapScriptSig := range input.TapScriptSig {
leafHash, err := chainhash.NewHash(tapScriptSig.LeafHash)
if err != nil {
return err
}
preimage, err := common.TaprootPreimage(
m.genesisBlockHash,
ptx,
index,
leafHash,
)
if err != nil {
return err
}
sig, err := schnorr.ParseSignature(tapScriptSig.Signature)
if err != nil {
return err
}
pubkey, err := schnorr.ParsePubKey(tapScriptSig.PubKey)
if err != nil {
return err
}
if sig.Verify(preimage, pubkey) {
if valid {
m.forfeitTxs[txid].tx = tx
m.forfeitTxs[txid].signed = true
} else {
return fmt.Errorf("invalid signature")
}
}
}
logrus.Warnf("invalid forfeit tx signature (%s)", txid)
}
}
}
@@ -293,8 +256,8 @@ func findSweepableOutputs(
if !node.Leaf {
children := congestionTree.Children(node.Txid)
newNodesToCheck = append(newNodesToCheck, children...)
continue
}
continue
}
if _, ok := sweepableOutputs[expirationTime]; !ok {
@@ -308,3 +271,13 @@ func findSweepableOutputs(
return sweepableOutputs, nil
}
func getSpentVtxos(payments map[string]domain.Payment) []domain.VtxoKey {
vtxos := make([]domain.VtxoKey, 0)
for _, p := range payments {
for _, vtxo := range p.Inputs {
vtxos = append(vtxos, vtxo.VtxoKey)
}
}
return vtxos
}

View File

@@ -14,4 +14,5 @@ type BlockchainScanner interface {
WatchScripts(ctx context.Context, scripts []string) error
UnwatchScripts(ctx context.Context, scripts []string) error
GetNotificationChannel(ctx context.Context) <-chan map[string]VtxoWithValue
IsTransactionConfirmed(ctx context.Context, txid string) (isConfirmed bool, blocktime int64, err error)
}

View File

@@ -17,9 +17,16 @@ type SweepInput interface {
}
type TxBuilder interface {
BuildPoolTx(aspPubkey *secp256k1.PublicKey, payments []domain.Payment, minRelayFee uint64, sweptRounds []domain.Round) (poolTx string, congestionTree tree.CongestionTree, connectorAddress string, err error)
BuildPoolTx(
aspPubkey *secp256k1.PublicKey, payments []domain.Payment, minRelayFee uint64, sweptRounds []domain.Round,
cosigners ...*secp256k1.PublicKey,
) (poolTx string, congestionTree tree.CongestionTree, connectorAddress string, err error)
BuildForfeitTxs(aspPubkey *secp256k1.PublicKey, poolTx string, payments []domain.Payment, minRelayFee uint64) (connectors []string, forfeitTxs []string, err error)
BuildSweepTx(inputs []SweepInput) (signedSweepTx string, err error)
GetVtxoScript(userPubkey, aspPubkey *secp256k1.PublicKey) ([]byte, error)
GetSweepInput(parentblocktime int64, node tree.Node) (expirationtime int64, sweepInput SweepInput, err error)
VerifyForfeitTx(tx string) (valid bool, txid string, err error)
FinalizeAndExtractForfeit(tx string) (txhex string, err error)
// FindLeaves returns all the leaves txs that are reachable from the given outpoint
FindLeaves(congestionTree tree.CongestionTree, fromtxid string, vout uint32) (leaves []tree.Node, err error)
}

View File

@@ -2,23 +2,26 @@ package ports
import (
"context"
"errors"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
)
// ErrNonFinalBIP68 is returned when a transaction spending a CSV-locked output is not final.
var ErrNonFinalBIP68 = errors.New("non-final BIP68 sequence")
type WalletService interface {
BlockchainScanner
Status(ctx context.Context) (WalletStatus, error)
GetPubkey(ctx context.Context) (*secp256k1.PublicKey, error)
DeriveConnectorAddress(ctx context.Context) (string, error)
DeriveAddresses(ctx context.Context, num int) ([]string, error)
SignPset(
ctx context.Context, pset string, extractRawTx bool,
SignTransaction(
ctx context.Context, partialTx string, extractRawTx bool,
) (string, error)
SignTransactionTapscript(ctx context.Context, pset string, inputIndexes []int) (string, error) // inputIndexes == nil means sign all inputs
SelectUtxos(ctx context.Context, asset string, amount uint64) ([]TxInput, uint64, error)
BroadcastTransaction(ctx context.Context, txHex string) (string, error)
SignPsetWithKey(ctx context.Context, pset string, inputIndexes []int) (string, error) // inputIndexes == nil means sign all inputs
IsTransactionConfirmed(ctx context.Context, txid string) (isConfirmed bool, blocktime int64, err error)
WaitForSync(ctx context.Context, txid string) error
EstimateFees(ctx context.Context, pset string) (uint64, error)
ListConnectorUtxos(ctx context.Context, connectorAddress string) ([]TxInput, error)

View File

@@ -5,9 +5,11 @@ import (
"encoding/hex"
"fmt"
"github.com/ark-network/ark/common"
"github.com/ark-network/ark/common/tree"
"github.com/ark-network/ark/internal/core/domain"
"github.com/ark-network/ark/internal/core/ports"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/vulpemventures/go-elements/address"
@@ -24,18 +26,18 @@ const (
type txBuilder struct {
wallet ports.WalletService
net *network.Network
net common.Network
roundLifetime int64 // in seconds
exitDelay int64 // in seconds
}
func NewTxBuilder(
wallet ports.WalletService,
net network.Network,
net common.Network,
roundLifetime int64,
exitDelay int64,
) ports.TxBuilder {
return &txBuilder{wallet, &net, roundLifetime, exitDelay}
return &txBuilder{wallet, net, roundLifetime, exitDelay}
}
func (b *txBuilder) GetVtxoScript(userPubkey, aspPubkey *secp256k1.PublicKey) ([]byte, error) {
@@ -50,7 +52,7 @@ func (b *txBuilder) BuildSweepTx(inputs []ports.SweepInput) (signedSweepTx strin
sweepPset, err := sweepTransaction(
b.wallet,
inputs,
b.net.AssetID,
b.onchainNetwork().AssetID,
)
if err != nil {
return "", err
@@ -62,7 +64,7 @@ func (b *txBuilder) BuildSweepTx(inputs []ports.SweepInput) (signedSweepTx strin
}
ctx := context.Background()
signedSweepPsetB64, err := b.wallet.SignPsetWithKey(ctx, sweepPsetBase64, nil)
signedSweepPsetB64, err := b.wallet.SignTransactionTapscript(ctx, sweepPsetBase64, nil)
if err != nil {
return "", err
}
@@ -111,6 +113,7 @@ func (b *txBuilder) BuildForfeitTxs(
func (b *txBuilder) BuildPoolTx(
aspPubkey *secp256k1.PublicKey, payments []domain.Payment, minRelayFee uint64, sweptRounds []domain.Round,
_ ...*secp256k1.PublicKey, // cosigners are not used in the covenant
) (poolTx string, congestionTree tree.CongestionTree, connectorAddress string, err error) {
// The creation of the tree and the pool tx are tightly coupled:
// - building the tree requires knowing the shared outpoint (txid:vout)
@@ -130,7 +133,7 @@ func (b *txBuilder) BuildPoolTx(
if !isOnchainOnly(payments) {
treeFactoryFn, sharedOutputScript, sharedOutputAmount, err = tree.CraftCongestionTree(
b.net.AssetID, aspPubkey, getOffchainReceivers(payments), minRelayFee, b.roundLifetime, b.exitDelay,
b.onchainNetwork().AssetID, aspPubkey, getOffchainReceivers(payments), minRelayFee, b.roundLifetime, b.exitDelay,
)
if err != nil {
return
@@ -211,6 +214,108 @@ func (b *txBuilder) GetSweepInput(parentblocktime int64, node tree.Node) (expira
return expirationTime, sweepInput, nil
}
func (b *txBuilder) VerifyForfeitTx(tx string) (bool, string, error) {
ptx, _ := psetv2.NewPsetFromBase64(tx)
utx, _ := ptx.UnsignedTx()
txid := utx.TxHash().String()
for index, input := range ptx.Inputs {
for _, tapScriptSig := range input.TapScriptSig {
leafHash, err := chainhash.NewHash(tapScriptSig.LeafHash)
if err != nil {
return false, txid, err
}
preimage, err := b.getTaprootPreimage(
tx,
index,
leafHash,
)
if err != nil {
return false, txid, err
}
sig, err := schnorr.ParseSignature(tapScriptSig.Signature)
if err != nil {
return false, txid, err
}
pubkey, err := schnorr.ParsePubKey(tapScriptSig.PubKey)
if err != nil {
return false, txid, err
}
if sig.Verify(preimage, pubkey) {
return true, txid, nil
} else {
return false, txid, fmt.Errorf("invalid signature")
}
}
}
return false, txid, nil
}
func (b *txBuilder) FinalizeAndExtractForfeit(tx string) (string, error) {
p, err := psetv2.NewPsetFromBase64(tx)
if err != nil {
return "", err
}
if err := psetv2.FinalizeAll(p); err != nil {
return "", err
}
// extract the forfeit tx
extracted, err := psetv2.Extract(p)
if err != nil {
return "", err
}
return extracted.ToHex()
}
func (b *txBuilder) FindLeaves(
congestionTree tree.CongestionTree,
fromtxid string,
fromvout uint32,
) ([]tree.Node, error) {
allLeaves := congestionTree.Leaves()
foundLeaves := make([]tree.Node, 0)
for _, leaf := range allLeaves {
branch, err := congestionTree.Branch(leaf.Txid)
if err != nil {
return nil, err
}
for _, node := range branch {
ptx, err := psetv2.NewPsetFromBase64(node.Tx)
if err != nil {
return nil, err
}
if len(ptx.Inputs) <= 0 {
return nil, fmt.Errorf("no input in the pset")
}
parentInput := ptx.Inputs[0]
hash, err := chainhash.NewHash(parentInput.PreviousTxid)
if err != nil {
return nil, err
}
if hash.String() == fromtxid && parentInput.PreviousTxIndex == fromvout {
foundLeaves = append(foundLeaves, leaf)
break
}
}
}
return foundLeaves, nil
}
func (b *txBuilder) getLeafScriptAndTree(
userPubkey, aspPubkey *secp256k1.PublicKey,
) ([]byte, *taproot.IndexedElementsTapScriptTree, error) {
@@ -255,7 +360,7 @@ func (b *txBuilder) createPoolTx(
payments []domain.Payment, aspPubKey *secp256k1.PublicKey, connectorAddress string, minRelayFee uint64,
sweptRounds []domain.Round,
) (*psetv2.Pset, error) {
aspScript, err := p2wpkhScript(aspPubKey, b.net)
aspScript, err := p2wpkhScript(aspPubKey, b.onchainNetwork())
if err != nil {
return nil, err
}
@@ -279,14 +384,14 @@ func (b *txBuilder) createPoolTx(
targetAmount += sharedOutputAmount
outputs = append(outputs, psetv2.OutputArgs{
Asset: b.net.AssetID,
Asset: b.onchainNetwork().AssetID,
Amount: sharedOutputAmount,
Script: sharedOutputScript,
})
}
outputs = append(outputs, psetv2.OutputArgs{
Asset: b.net.AssetID,
Asset: b.onchainNetwork().AssetID,
Amount: connectorsAmount,
Script: connectorScript,
})
@@ -300,7 +405,7 @@ func (b *txBuilder) createPoolTx(
}
outputs = append(outputs, psetv2.OutputArgs{
Asset: b.net.AssetID,
Asset: b.onchainNetwork().AssetID,
Amount: receiver.Amount,
Script: receiverScript,
})
@@ -319,7 +424,7 @@ func (b *txBuilder) createPoolTx(
change = 0
} else {
outputs = append(outputs, psetv2.OutputArgs{
Asset: b.net.AssetID,
Asset: b.onchainNetwork().AssetID,
Amount: change,
Script: aspScript,
})
@@ -377,7 +482,7 @@ func (b *txBuilder) createPoolTx(
if change > 0 {
if err := updater.AddOutputs([]psetv2.OutputArgs{
{
Asset: b.net.AssetID,
Asset: b.onchainNetwork().AssetID,
Amount: change,
Script: aspScript,
},
@@ -402,7 +507,7 @@ func (b *txBuilder) createPoolTx(
} else {
if err := updater.AddOutputs([]psetv2.OutputArgs{
{
Asset: b.net.AssetID,
Asset: b.onchainNetwork().AssetID,
Amount: change,
Script: aspScript,
},
@@ -420,7 +525,7 @@ func (b *txBuilder) createPoolTx(
// add fee output
if err := updater.AddOutputs([]psetv2.OutputArgs{
{
Asset: b.net.AssetID,
Asset: b.onchainNetwork().AssetID,
Amount: feeAmount,
},
}); err != nil {
@@ -441,7 +546,7 @@ func (b *txBuilder) createConnectors(
}
connectorOutput := psetv2.OutputArgs{
Asset: b.net.AssetID,
Asset: b.onchainNetwork().AssetID,
Script: aspScript,
Amount: connectorAmount,
}
@@ -475,7 +580,7 @@ func (b *txBuilder) createConnectors(
totalConnectorAmount -= minRelayFee
if totalConnectorAmount > 0 {
outputs = append(outputs, psetv2.OutputArgs{
Asset: b.net.AssetID,
Asset: b.onchainNetwork().AssetID,
Script: aspScript,
Amount: totalConnectorAmount,
})
@@ -501,7 +606,7 @@ func (b *txBuilder) createConnectors(
func (b *txBuilder) createForfeitTxs(
aspPubkey *secp256k1.PublicKey, payments []domain.Payment, connectors []*psetv2.Pset,
) ([]string, error) {
aspScript, err := p2wpkhScript(aspPubkey, b.net)
aspScript, err := p2wpkhScript(aspPubkey, b.onchainNetwork())
if err != nil {
return nil, err
}
@@ -567,7 +672,7 @@ func (b *txBuilder) getConnectorAddress(poolTx string) (string, error) {
connectorOutput := pset.Outputs[1]
pay, err := payment.FromScript(connectorOutput.Script, b.net, nil)
pay, err := payment.FromScript(connectorOutput.Script, b.onchainNetwork(), nil)
if err != nil {
return "", err
}
@@ -575,6 +680,53 @@ func (b *txBuilder) getConnectorAddress(poolTx string) (string, error) {
return pay.WitnessPubKeyHash()
}
func (b *txBuilder) getTaprootPreimage(tx string, inputIndex int, leafHash *chainhash.Hash) ([]byte, error) {
pset, err := psetv2.NewPsetFromBase64(tx)
if err != nil {
return nil, err
}
prevoutScripts := make([][]byte, 0)
prevoutAssets := make([][]byte, 0)
prevoutValues := make([][]byte, 0)
for i, input := range pset.Inputs {
if input.WitnessUtxo == nil {
return nil, fmt.Errorf("missing witness utxo on input #%d", i)
}
prevoutScripts = append(prevoutScripts, input.WitnessUtxo.Script)
prevoutAssets = append(prevoutAssets, input.WitnessUtxo.Asset)
prevoutValues = append(prevoutValues, input.WitnessUtxo.Value)
}
utx, err := pset.UnsignedTx()
if err != nil {
return nil, err
}
genesisHash, _ := chainhash.NewHashFromStr(b.onchainNetwork().GenesisBlockHash)
preimage := utx.HashForWitnessV1(
inputIndex, prevoutScripts, prevoutAssets, prevoutValues,
pset.Inputs[inputIndex].SigHashType, genesisHash, leafHash, nil,
)
return preimage[:], nil
}
func (b *txBuilder) onchainNetwork() *network.Network {
switch b.net.Name {
case common.Liquid.Name:
return &network.Liquid
case common.LiquidTestNet.Name:
return &network.Testnet
case common.LiquidRegTest.Name:
return &network.Regtest
default:
return &network.Liquid
}
}
func extractSweepLeaf(input psetv2.Input) (sweepLeaf *psetv2.TapLeafScript, lifetime int64, err error) {
for _, leaf := range input.TapLeafScript {
closure := &tree.CSVSigClosure{}

View File

@@ -7,6 +7,7 @@ import (
"os"
"testing"
"github.com/ark-network/ark/common"
"github.com/ark-network/ark/common/tree"
"github.com/ark-network/ark/internal/core/domain"
"github.com/ark-network/ark/internal/core/ports"
@@ -15,7 +16,6 @@ import (
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/vulpemventures/go-elements/network"
"github.com/vulpemventures/go-elements/psetv2"
)
@@ -49,7 +49,7 @@ func TestMain(m *testing.M) {
func TestBuildPoolTx(t *testing.T) {
builder := txbuilder.NewTxBuilder(
wallet, network.Liquid, roundLifetime, unilateralExitDelay,
wallet, common.Liquid, roundLifetime, unilateralExitDelay,
)
fixtures, err := parsePoolTxFixtures()
@@ -94,7 +94,7 @@ func TestBuildPoolTx(t *testing.T) {
func TestBuildForfeitTxs(t *testing.T) {
builder := txbuilder.NewTxBuilder(
wallet, network.Liquid, 1209344, unilateralExitDelay,
wallet, common.Liquid, 1209344, unilateralExitDelay,
)
fixtures, err := parseForfeitTxsFixtures()

View File

@@ -40,7 +40,7 @@ func (b *txBuilder) selectUtxos(ctx context.Context, sweptRounds []domain.Round,
return selectedConnectorsUtxos, selectedConnectorsAmount - amount, nil
}
utxos, change, err := b.wallet.SelectUtxos(ctx, b.net.AssetID, amount-selectedConnectorsAmount)
utxos, change, err := b.wallet.SelectUtxos(ctx, b.onchainNetwork().AssetID, amount-selectedConnectorsAmount)
if err != nil {
return nil, 0, err
}

View File

@@ -61,8 +61,8 @@ func (m *mockedWallet) GetPubkey(ctx context.Context) (*secp256k1.PublicKey, err
return res, args.Error(1)
}
// SignPset implements ports.WalletService.
func (m *mockedWallet) SignPset(ctx context.Context, pset string, extractRawTx bool) (string, error) {
// SignTransaction implements ports.WalletService.
func (m *mockedWallet) SignTransaction(ctx context.Context, pset string, extractRawTx bool) (string, error) {
args := m.Called(ctx, pset, extractRawTx)
var res string
@@ -123,7 +123,7 @@ func (m *mockedWallet) IsTransactionConfirmed(ctx context.Context, txid string)
return res, blocktime, args.Error(2)
}
func (m *mockedWallet) SignPsetWithKey(ctx context.Context, pset string, inputIndexes []int) (string, error) {
func (m *mockedWallet) SignTransactionTapscript(ctx context.Context, pset string, inputIndexes []int) (string, error) {
args := m.Called(ctx, pset, inputIndexes)
var res string

View File

@@ -7,10 +7,12 @@ import (
"fmt"
"strings"
"github.com/ark-network/ark/common"
"github.com/ark-network/ark/common/bitcointree"
"github.com/ark-network/ark/common/tree"
"github.com/ark-network/ark/internal/core/domain"
"github.com/ark-network/ark/internal/core/ports"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/chaincfg"
@@ -18,7 +20,6 @@ import (
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/decred/dcrd/dcrec/secp256k1/v4/schnorr"
)
const (
@@ -28,17 +29,76 @@ const (
type txBuilder struct {
wallet ports.WalletService
net *chaincfg.Params
net common.Network
roundLifetime int64 // in seconds
exitDelay int64 // in seconds
}
func NewTxBuilder(
wallet ports.WalletService, net *chaincfg.Params, roundLifetime int64, exitDelay int64,
wallet ports.WalletService, net common.Network, roundLifetime int64, exitDelay int64,
) ports.TxBuilder {
return &txBuilder{wallet, net, roundLifetime, exitDelay}
}
func (b *txBuilder) VerifyForfeitTx(tx string) (bool, string, error) {
ptx, _ := psbt.NewFromRawBytes(strings.NewReader(tx), true)
txid := ptx.UnsignedTx.TxHash().String()
for index, input := range ptx.Inputs {
for _, tapScriptSig := range input.TaprootScriptSpendSig {
preimage, err := b.getTaprootPreimage(
tx,
index,
input.TaprootLeafScript[0].Script,
)
if err != nil {
return false, txid, err
}
sig, err := schnorr.ParseSignature(tapScriptSig.Signature)
if err != nil {
return false, txid, err
}
pubkey, err := schnorr.ParsePubKey(tapScriptSig.XOnlyPubKey)
if err != nil {
return false, txid, err
}
if sig.Verify(preimage, pubkey) {
return true, txid, nil
} else {
return false, txid, fmt.Errorf("invalid signature for tx %s", txid)
}
}
}
return false, txid, nil
}
func (b *txBuilder) FinalizeAndExtractForfeit(tx string) (string, error) {
ptx, _ := psbt.NewFromRawBytes(strings.NewReader(tx), true)
for i := range ptx.Inputs {
if err := psbt.Finalize(ptx, i); err != nil {
return "", err
}
}
signed, err := psbt.Extract(ptx)
if err != nil {
return "", err
}
var serialized bytes.Buffer
if err := signed.Serialize(&serialized); err != nil {
return "", err
}
return hex.EncodeToString(serialized.Bytes()), nil
}
func (b *txBuilder) GetVtxoScript(userPubkey, aspPubkey *secp256k1.PublicKey) ([]byte, error) {
outputScript, _, err := b.getLeafScriptAndTree(userPubkey, aspPubkey)
if err != nil {
@@ -62,7 +122,7 @@ func (b *txBuilder) BuildSweepTx(inputs []ports.SweepInput) (signedSweepTx strin
}
ctx := context.Background()
signedSweepPsbtB64, err := b.wallet.SignPsetWithKey(ctx, sweepPsbtBase64, nil)
signedSweepPsbtB64, err := b.wallet.SignTransactionTapscript(ctx, sweepPsbtBase64, nil)
if err != nil {
return "", err
}
@@ -118,18 +178,15 @@ func (b *txBuilder) BuildForfeitTxs(
}
func (b *txBuilder) BuildPoolTx(
aspPubkey *secp256k1.PublicKey, payments []domain.Payment, minRelayFee uint64, sweptRounds []domain.Round,
aspPubkey *secp256k1.PublicKey, payments []domain.Payment, minRelayFee uint64, sweptRounds []domain.Round, cosigners ...*secp256k1.PublicKey,
) (poolTx string, congestionTree tree.CongestionTree, connectorAddress string, err error) {
var sharedOutputScript []byte
var sharedOutputAmount int64
var senders []*secp256k1.PublicKey
senders, err = getCosigners(payments)
if err != nil {
return
if len(cosigners) == 0 {
return "", nil, "", fmt.Errorf("missing cosigners")
}
cosigners := append(senders, aspPubkey)
receivers := getOffchainReceivers(payments)
if !isOnchainOnly(payments) {
@@ -147,7 +204,7 @@ func (b *txBuilder) BuildPoolTx(
}
ptx, err := b.createPoolTx(
sharedOutputAmount, sharedOutputScript, payments, aspPubkey, connectorAddress, minRelayFee, sweptRounds,
sharedOutputAmount, sharedOutputScript, payments, connectorAddress, minRelayFee, sweptRounds,
)
if err != nil {
return
@@ -214,6 +271,38 @@ func (b *txBuilder) GetSweepInput(parentblocktime int64, node tree.Node) (expira
return expirationTime, sweepInput, nil
}
func (b *txBuilder) FindLeaves(congestionTree tree.CongestionTree, fromtxid string, vout uint32) ([]tree.Node, error) {
allLeaves := congestionTree.Leaves()
foundLeaves := make([]tree.Node, 0)
for _, leaf := range allLeaves {
branch, err := congestionTree.Branch(leaf.Txid)
if err != nil {
return nil, err
}
for _, node := range branch {
ptx, err := psbt.NewFromRawBytes(strings.NewReader(node.Tx), true)
if err != nil {
return nil, err
}
if len(ptx.Inputs) <= 0 {
return nil, fmt.Errorf("no input in the pset")
}
parentInput := ptx.UnsignedTx.TxIn[0].PreviousOutPoint
if parentInput.Hash.String() == fromtxid && parentInput.Index == vout {
foundLeaves = append(foundLeaves, leaf)
break
}
}
}
return foundLeaves, nil
}
func (b *txBuilder) getLeafScriptAndTree(
userPubkey, aspPubkey *secp256k1.PublicKey,
) ([]byte, *txscript.IndexedTapScriptTree, error) {
@@ -242,7 +331,7 @@ func (b *txBuilder) getLeafScriptAndTree(
)
root := taprootTree.RootNode.TapHash()
unspendableKey := tree.UnspendableKey()
unspendableKey := bitcointree.UnspendableKey()
taprootKey := txscript.ComputeTaprootOutputKey(unspendableKey, root[:])
outputScript, err := taprootOutputScript(taprootKey)
@@ -255,15 +344,10 @@ func (b *txBuilder) getLeafScriptAndTree(
func (b *txBuilder) createPoolTx(
sharedOutputAmount int64, sharedOutputScript []byte,
payments []domain.Payment, aspPubKey *secp256k1.PublicKey, connectorAddress string, minRelayFee uint64,
payments []domain.Payment, connectorAddress string, minRelayFee uint64,
sweptRounds []domain.Round,
) (*psbt.Packet, error) {
aspScript, err := p2trScript(aspPubKey, b.net)
if err != nil {
return nil, err
}
connectorAddr, err := btcutil.DecodeAddress(connectorAddress, b.net)
connectorAddr, err := btcutil.DecodeAddress(connectorAddress, b.onchainNetwork())
if err != nil {
return nil, err
}
@@ -300,7 +384,7 @@ func (b *txBuilder) createPoolTx(
for _, receiver := range receivers {
targetAmount += receiver.Amount
receiverAddr, err := btcutil.DecodeAddress(receiver.OnchainAddress, b.net)
receiverAddr, err := btcutil.DecodeAddress(receiver.OnchainAddress, b.onchainNetwork())
if err != nil {
return nil, err
}
@@ -328,6 +412,21 @@ func (b *txBuilder) createPoolTx(
dust = change
change = 0
} else {
address, err := b.wallet.DeriveAddresses(ctx, 1)
if err != nil {
return nil, err
}
addr, err := btcutil.DecodeAddress(address[0], b.onchainNetwork())
if err != nil {
return nil, err
}
aspScript, err := txscript.PayToAddrScript(addr)
if err != nil {
return nil, err
}
outputs = append(outputs, &wire.TxOut{
Value: int64(change),
PkScript: aspScript,
@@ -336,6 +435,7 @@ func (b *txBuilder) createPoolTx(
}
ins := make([]*wire.OutPoint, 0)
nSequences := make([]uint32, 0)
for _, utxo := range utxos {
txhash, err := chainhash.NewHashFromStr(utxo.GetTxid())
@@ -347,9 +447,10 @@ func (b *txBuilder) createPoolTx(
Hash: *txhash,
Index: utxo.GetIndex(),
})
nSequences = append(nSequences, wire.MaxTxInSequenceNum)
}
ptx, err := psbt.New(ins, outputs, 2, 0, []uint32{wire.MaxTxInSequenceNum})
ptx, err := psbt.New(ins, outputs, 2, 0, nSequences)
if err != nil {
return nil, err
}
@@ -409,6 +510,21 @@ func (b *txBuilder) createPoolTx(
}
if change > 0 {
address, err := b.wallet.DeriveAddresses(ctx, 1)
if err != nil {
return nil, err
}
addr, err := btcutil.DecodeAddress(address[0], b.onchainNetwork())
if err != nil {
return nil, err
}
aspScript, err := txscript.PayToAddrScript(addr)
if err != nil {
return nil, err
}
ptx.UnsignedTx.AddTxOut(&wire.TxOut{
Value: int64(change),
PkScript: aspScript,
@@ -455,6 +571,21 @@ func (b *txBuilder) createPoolTx(
if change > 0 {
if change > dustLimit {
address, err := b.wallet.DeriveAddresses(ctx, 1)
if err != nil {
return nil, err
}
addr, err := btcutil.DecodeAddress(address[0], b.onchainNetwork())
if err != nil {
return nil, err
}
aspScript, err := txscript.PayToAddrScript(addr)
if err != nil {
return nil, err
}
ptx.UnsignedTx.AddTxOut(&wire.TxOut{
Value: int64(change),
PkScript: aspScript,
@@ -562,7 +693,7 @@ func (b *txBuilder) createConnectors(
func (b *txBuilder) createForfeitTxs(
aspPubkey *secp256k1.PublicKey, payments []domain.Payment, connectors []*psbt.Packet, minRelayFee uint64,
) ([]string, error) {
aspScript, err := p2trScript(aspPubkey, b.net)
aspScript, err := p2wpkhScript(aspPubkey, b.onchainNetwork())
if err != nil {
return nil, err
}
@@ -601,9 +732,21 @@ func (b *txBuilder) createForfeitTxs(
return nil, fmt.Errorf("forfeit proof not found")
}
controlBlock := forfeitProof.ToControlBlock(bitcointree.UnspendableKey())
ctrlBlockBytes, err := controlBlock.ToBytes()
if err != nil {
return nil, err
}
for _, connector := range connectors {
txs, err := craftForfeitTxs(
connector, vtxo, vtxoScript, aspScript, minRelayFee,
connector, vtxo,
&psbt.TaprootTapLeafScript{
ControlBlock: ctrlBlockBytes,
Script: forfeitProof.Script,
LeafVersion: forfeitProof.LeafVersion,
},
vtxoScript, aspScript, minRelayFee,
)
if err != nil {
return nil, err
@@ -670,6 +813,48 @@ func (b *txBuilder) selectUtxos(ctx context.Context, sweptRounds []domain.Round,
return append(selectedConnectorsUtxos, utxos...), change, nil
}
func (b *txBuilder) getTaprootPreimage(tx string, inputIndex int, leafScript []byte) ([]byte, error) {
partial, err := psbt.NewFromRawBytes(strings.NewReader(tx), true)
if err != nil {
return nil, err
}
prevouts := make(map[wire.OutPoint]*wire.TxOut)
for i, input := range partial.Inputs {
if input.WitnessUtxo == nil {
return nil, fmt.Errorf("missing witness utxo on input #%d", i)
}
outpoint := partial.UnsignedTx.TxIn[i].PreviousOutPoint
prevouts[outpoint] = input.WitnessUtxo
}
prevoutFetcher := txscript.NewMultiPrevOutFetcher(prevouts)
return txscript.CalcTapscriptSignaturehash(
txscript.NewTxSigHashes(partial.UnsignedTx, prevoutFetcher),
txscript.SigHashDefault,
partial.UnsignedTx,
inputIndex,
prevoutFetcher,
txscript.NewBaseTapLeaf(leafScript),
)
}
func (b *txBuilder) onchainNetwork() *chaincfg.Params {
switch b.net.Name {
case common.Bitcoin.Name:
return &chaincfg.MainNetParams
case common.BitcoinTestNet.Name:
return &chaincfg.TestNet3Params
case common.BitcoinRegTest.Name:
return &chaincfg.RegressionNetParams
default:
return nil
}
}
func castToOutpoints(inputs []ports.TxInput) []ports.TxOutpoint {
outpoints := make([]ports.TxOutpoint, 0, len(inputs))
for _, input := range inputs {

View File

@@ -8,12 +8,12 @@ import (
"strings"
"testing"
"github.com/ark-network/ark/common"
"github.com/ark-network/ark/common/bitcointree"
"github.com/ark-network/ark/internal/core/domain"
"github.com/ark-network/ark/internal/core/ports"
txbuilder "github.com/ark-network/ark/internal/infrastructure/tx-builder/covenantless"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/chaincfg"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
@@ -49,7 +49,7 @@ func TestMain(m *testing.M) {
func TestBuildPoolTx(t *testing.T) {
builder := txbuilder.NewTxBuilder(
wallet, &chaincfg.MainNetParams, roundLifetime, unilateralExitDelay,
wallet, common.Bitcoin, roundLifetime, unilateralExitDelay,
)
fixtures, err := parsePoolTxFixtures()
@@ -59,16 +59,6 @@ func TestBuildPoolTx(t *testing.T) {
if len(fixtures.Valid) > 0 {
t.Run("valid", func(t *testing.T) {
for _, f := range fixtures.Valid {
poolTx, congestionTree, connAddr, err := builder.BuildPoolTx(
pubkey, f.Payments, minRelayFee, []domain.Round{},
)
require.NoError(t, err)
require.NotEmpty(t, poolTx)
require.NotEmpty(t, congestionTree)
require.Equal(t, connectorAddress, connAddr)
require.Equal(t, f.ExpectedNumOfNodes, congestionTree.NumberOfNodes())
require.Len(t, congestionTree.Leaves(), f.ExpectedNumOfLeaves)
cosigners := make([]*secp256k1.PublicKey, 0)
for _, payment := range f.Payments {
for _, input := range payment.Inputs {
@@ -81,8 +71,18 @@ func TestBuildPoolTx(t *testing.T) {
}
}
poolTx, congestionTree, connAddr, err := builder.BuildPoolTx(
pubkey, f.Payments, minRelayFee, []domain.Round{}, cosigners...,
)
require.NoError(t, err)
require.NotEmpty(t, poolTx)
require.NotEmpty(t, congestionTree)
require.Equal(t, connectorAddress, connAddr)
require.Equal(t, f.ExpectedNumOfNodes, congestionTree.NumberOfNodes())
require.Len(t, congestionTree.Leaves(), f.ExpectedNumOfLeaves)
err = bitcointree.ValidateCongestionTree(
congestionTree, poolTx, pubkey, roundLifetime, cosigners, int64(minRelayFee),
congestionTree, poolTx, pubkey, roundLifetime, int64(minRelayFee),
)
require.NoError(t, err)
}
@@ -106,7 +106,7 @@ func TestBuildPoolTx(t *testing.T) {
func TestBuildForfeitTxs(t *testing.T) {
builder := txbuilder.NewTxBuilder(
wallet, &chaincfg.MainNetParams, 1209344, unilateralExitDelay,
wallet, common.Bitcoin, 1209344, unilateralExitDelay,
)
fixtures, err := parseForfeitTxsFixtures()

View File

@@ -11,6 +11,7 @@ import (
func craftForfeitTxs(
connectorTx *psbt.Packet,
vtxo domain.Vtxo,
vtxoForfeitTapLeaf *psbt.TaprootTapLeafScript,
vtxoScript, aspScript []byte,
minRelayFee uint64,
) (forfeitTxs []string, err error) {
@@ -63,6 +64,8 @@ func craftForfeitTxs(
return nil, err
}
updater.Upsbt.Inputs[1].TaprootLeafScript = []*psbt.TaprootTapLeafScript{vtxoForfeitTapLeaf}
tx, err := partialTx.B64Encode()
if err != nil {
return nil, err

View File

@@ -61,8 +61,8 @@ func (m *mockedWallet) GetPubkey(ctx context.Context) (*secp256k1.PublicKey, err
return res, args.Error(1)
}
// SignPset implements ports.WalletService.
func (m *mockedWallet) SignPset(ctx context.Context, pset string, extractRawTx bool) (string, error) {
// SignTransaction implements ports.WalletService.
func (m *mockedWallet) SignTransaction(ctx context.Context, pset string, extractRawTx bool) (string, error) {
args := m.Called(ctx, pset, extractRawTx)
var res string
@@ -123,7 +123,7 @@ func (m *mockedWallet) IsTransactionConfirmed(ctx context.Context, txid string)
return res, blocktime, args.Error(2)
}
func (m *mockedWallet) SignPsetWithKey(ctx context.Context, pset string, inputIndexes []int) (string, error) {
func (m *mockedWallet) SignTransactionTapscript(ctx context.Context, pset string, inputIndexes []int) (string, error) {
args := m.Called(ctx, pset, inputIndexes)
var res string

View File

@@ -2,6 +2,7 @@ package txbuilder
import (
"context"
"encoding/hex"
"fmt"
"github.com/ark-network/ark/common"
@@ -32,6 +33,9 @@ func sweepTransaction(
if err != nil {
return nil, err
}
fmt.Println("sweepClosure.Pubkey", hex.EncodeToString(sweepClosure.Pubkey.SerializeCompressed()))
if !valid {
return nil, fmt.Errorf("invalid csv script")
}

View File

@@ -1,8 +1,6 @@
package txbuilder
import (
"encoding/hex"
"github.com/ark-network/ark/common/bitcointree"
"github.com/ark-network/ark/internal/core/domain"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
@@ -12,18 +10,18 @@ import (
"github.com/decred/dcrd/dcrec/secp256k1/v4"
)
func p2trScript(publicKey *secp256k1.PublicKey, net *chaincfg.Params) ([]byte, error) {
func p2wpkhScript(publicKey *secp256k1.PublicKey, net *chaincfg.Params) ([]byte, error) {
tapKey := txscript.ComputeTaprootKeyNoScript(publicKey)
payment, err := btcutil.NewAddressTaproot(
schnorr.SerializePubKey(tapKey),
payment, err := btcutil.NewAddressWitnessPubKeyHash(
btcutil.Hash160(tapKey.SerializeCompressed()),
net,
)
if err != nil {
return nil, err
}
return payment.ScriptAddress(), nil
return txscript.PayToAddrScript(payment)
}
func getOnchainReceivers(
@@ -40,31 +38,6 @@ func getOnchainReceivers(
return receivers
}
// TODO: use ephemeral keys ?
func getCosigners(
payments []domain.Payment,
) ([]*secp256k1.PublicKey, error) {
cosigners := make([]*secp256k1.PublicKey, 0)
for _, payment := range payments {
for _, input := range payment.Inputs {
pubkeyBytes, err := hex.DecodeString(input.Pubkey)
if err != nil {
return nil, err
}
pubkey, err := secp256k1.ParsePubKey(pubkeyBytes)
if err != nil {
return nil, err
}
cosigners = append(cosigners, pubkey)
}
}
return cosigners, nil
}
func getOffchainReceivers(
payments []domain.Payment,
) []bitcointree.Receiver {

View File

@@ -0,0 +1,116 @@
package btcwallet
import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"strings"
"github.com/ark-network/ark/internal/core/ports"
"github.com/btcsuite/btcd/btcutil"
log "github.com/sirupsen/logrus"
)
type esploraClient struct {
url string
}
type esploraTx struct {
Status struct {
Confirmed bool `json:"confirmed"`
BlockTime int64 `json:"block_time"`
} `json:"status"`
}
func (f *esploraClient) broadcast(txhex string) error {
endpoint, err := url.JoinPath(f.url, "tx")
if err != nil {
return err
}
resp, err := http.Post(endpoint, "text/plain", strings.NewReader(txhex))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
content, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
if strings.Contains(strings.ToLower(string(content)), "non-BIP68-final") {
return ports.ErrNonFinalBIP68
}
return fmt.Errorf("failed to broadcast transaction: %s (%s, %s)", txhex, resp.Status, content)
}
return nil
}
func (f *esploraClient) getTxStatus(txid string) (isConfirmed bool, blocktime int64, err error) {
endpoint, err := url.JoinPath(f.url, "tx", txid)
if err != nil {
return false, 0, err
}
resp, err := http.DefaultClient.Get(endpoint)
if err != nil {
return false, 0, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return false, 0, err
}
var response esploraTx
if err := json.NewDecoder(resp.Body).Decode(&response); err != nil {
return false, 0, err
}
return response.Status.Confirmed, response.Status.BlockTime, nil
}
func (f *esploraClient) getFeeRate() (btcutil.Amount, error) {
endpoint, err := url.JoinPath(f.url, "fee-estimates")
if err != nil {
return 0, err
}
resp, err := http.DefaultClient.Get(endpoint)
if err != nil {
return 0, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return 0, errors.New("fee-estimates endpoint HTTP error: " + resp.Status)
}
response := make(map[string]float64)
if err := json.NewDecoder(resp.Body).Decode(&response); err != nil {
return 0, err
}
if len(response) == 0 {
log.Warn("empty response from esplora fee-estimates endpoint, default to 2 sat/vbyte")
return 2.0, nil
}
feeRate, ok := response["1"]
if !ok {
return 0, errors.New("failed to get fee rate for 1 block")
}
return btcutil.Amount(feeRate * 1000), nil
}

View File

@@ -0,0 +1,57 @@
package btcwallet
import (
"encoding/hex"
"github.com/btcsuite/btcwallet/wallet"
)
// transactionOutputTxInput is a wrapper around wallet.TransactionOutput implementing the ports.TxInput interface
type transactionOutputTxInput struct {
*wallet.TransactionOutput
}
func (t transactionOutputTxInput) GetAsset() string {
panic("ports.TxInput.GetAsset unimplemented on Bitcoin network") // liquid only
}
func (t transactionOutputTxInput) GetIndex() uint32 {
return t.OutPoint.Index
}
func (t transactionOutputTxInput) GetScript() string {
return hex.EncodeToString(t.Output.PkScript)
}
func (t transactionOutputTxInput) GetTxid() string {
return t.OutPoint.Hash.String()
}
func (t transactionOutputTxInput) GetValue() uint64 {
return uint64(t.Output.Value)
}
// coinTxInput is a wrapper around wallet.Coin implementing the ports.TxInput interface
type coinTxInput struct {
wallet.Coin
}
func (c coinTxInput) GetAsset() string {
panic("ports.TxInput.GetAsset unimplemented on Bitcoin network") // liquid only
}
func (c coinTxInput) GetIndex() uint32 {
return c.OutPoint.Index
}
func (c coinTxInput) GetScript() string {
return hex.EncodeToString(c.TxOut.PkScript)
}
func (c coinTxInput) GetTxid() string {
return c.OutPoint.Hash.String()
}
func (c coinTxInput) GetValue() uint64 {
return uint64(c.TxOut.Value)
}

View File

@@ -0,0 +1,132 @@
package btcwallet
import (
"fmt"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/btcutil/hdkeychain"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcwallet/waddrmgr"
log "github.com/sirupsen/logrus"
)
func (s *service) signPsbt(packet *psbt.Packet) ([]uint32, error) {
// iterates over the inputs and set the default sighash flags
updater, err := psbt.NewUpdater(packet)
if err != nil {
return nil, err
}
for idx, input := range packet.Inputs {
if input.WitnessUtxo == nil {
continue
}
script, err := txscript.ParsePkScript(input.WitnessUtxo.PkScript)
if err != nil {
return nil, fmt.Errorf("error detecting signing method, "+
"couldn't parse pkScript: %v", err)
}
sighashType := txscript.SigHashAll
if script.Class() == txscript.WitnessV1TaprootTy {
sighashType = txscript.SigHashDefault
}
if err := updater.AddInSighashType(sighashType, idx); err != nil {
return nil, err
}
}
tx := packet.UnsignedTx
for idx := range tx.TxIn {
in := &packet.Inputs[idx]
// skip if the input does not have a witness utxo
if in.WitnessUtxo == nil {
continue
}
// skip if already signed
if len(in.FinalScriptWitness) > 0 {
continue
}
var managedAddress waddrmgr.ManagedPubKeyAddress
var isTaproot bool
if len(in.TaprootLeafScript) > 0 && txscript.IsPayToTaproot(in.WitnessUtxo.PkScript) {
// segwit v1
isTaproot = true
managedAddress = s.aspTaprootAddr
} else {
// segwit v0
managedAddress, _, _, err = s.wallet.ScriptForOutput(in.WitnessUtxo)
if err != nil {
log.Debugf("SignPsbt: Skipping input %d, error "+
"fetching script for output: %v", idx, err)
continue
}
}
bip32Infos := derivationPathForAddress(managedAddress)
packet.Inputs[idx].Bip32Derivation = []*psbt.Bip32Derivation{bip32Infos}
if isTaproot {
leafHashes := make([][]byte, 0, len(in.TaprootLeafScript))
for _, leafScript := range in.TaprootLeafScript {
leafHash := txscript.NewBaseTapLeaf(leafScript.Script).TapHash()
leafHashes = append(leafHashes, leafHash[:])
}
xonlypubkey := schnorr.SerializePubKey(managedAddress.PubKey())
packet.Inputs[idx].TaprootBip32Derivation = []*psbt.TaprootBip32Derivation{
{
XOnlyPubKey: xonlypubkey,
MasterKeyFingerprint: bip32Infos.MasterKeyFingerprint,
Bip32Path: bip32Infos.Bip32Path,
LeafHashes: leafHashes,
},
}
}
}
// prevOutputFetcher := wallet.PsbtPrevOutputFetcher(packet)
// sigHashes := txscript.NewTxSigHashes(tx, prevOutputFetcher)
// in := packet.Inputs[0]
// preimage, err := txscript.CalcTapscriptSignaturehash(
// sigHashes,
// txscript.SigHashType(in.SighashType),
// tx,
// 0,
// txscript.NewCannedPrevOutputFetcher(in.WitnessUtxo.PkScript, in.WitnessUtxo.Value),
// txscript.NewBaseTapLeaf(in.TaprootLeafScript[0].Script),
// )
// if err != nil {
// return nil, err
// }
// fmt.Println("PREIMAGE", hex.EncodeToString(preimage))
return s.wallet.SignPsbt(packet)
}
func derivationPathForAddress(addr waddrmgr.ManagedPubKeyAddress) *psbt.Bip32Derivation {
keyscope, derivationInfos, _ := addr.DerivationInfo()
return &psbt.Bip32Derivation{
PubKey: addr.PubKey().SerializeCompressed(),
MasterKeyFingerprint: derivationInfos.MasterKeyFingerprint,
Bip32Path: []uint32{
keyscope.Purpose + hdkeychain.HardenedKeyStart,
keyscope.Coin + hdkeychain.HardenedKeyStart,
derivationInfos.Account,
derivationInfos.Branch,
derivationInfos.Index,
},
}
}

View File

@@ -0,0 +1,779 @@
package btcwallet
import (
"bytes"
"context"
"encoding/hex"
"errors"
"fmt"
"strings"
"sync"
"time"
"github.com/ark-network/ark/common"
"github.com/ark-network/ark/internal/core/domain"
"github.com/ark-network/ark/internal/core/ports"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btclog"
"github.com/btcsuite/btcwallet/chain"
"github.com/btcsuite/btcwallet/waddrmgr"
"github.com/btcsuite/btcwallet/wallet"
"github.com/btcsuite/btcwallet/walletdb"
_ "github.com/btcsuite/btcwallet/walletdb/bdb"
"github.com/btcsuite/btcwallet/wtxmgr"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/lightninglabs/neutrino"
"github.com/lightningnetwork/lnd/blockcache"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/btcwallet"
log "github.com/sirupsen/logrus"
)
type WalletOption func(*service) error
type WalletConfig struct {
Datadir string
Password []byte
Network common.Network
EsploraURL string
}
func (c WalletConfig) chainParams() *chaincfg.Params {
switch c.Network.Name {
case common.Bitcoin.Name:
return &chaincfg.MainNetParams
case common.BitcoinTestNet.Name:
return &chaincfg.TestNet3Params
case common.BitcoinRegTest.Name:
return &chaincfg.RegressionNetParams
default:
return &chaincfg.MainNetParams
}
}
type accountName string
const (
mainAccount accountName = "main"
connectorAccount accountName = "connector"
aspKeyAccount accountName = "aspkey"
)
var (
p2wpkhKeyScope = waddrmgr.KeyScopeBIP0084
p2trKeyScope = waddrmgr.KeyScopeBIP0086
outputLockDuration = time.Minute
)
type service struct {
wallet *btcwallet.BtcWallet
cfg WalletConfig
chainSource chain.Interface
scanner chain.Interface
esploraClient *esploraClient
watchedScriptsLock sync.RWMutex
watchedScripts map[string]struct{}
aspTaprootAddr waddrmgr.ManagedPubKeyAddress
}
// WithNeutrino creates a start a neutrino node using the provided service datadir
func WithNeutrino(initialPeer string) WalletOption {
return func(s *service) error {
if s.cfg.Network.Name == common.BitcoinRegTest.Name && len(initialPeer) == 0 {
return errors.New("initial neutrino peer required for regtest network, set NEUTRINO_PEER env var")
}
db, err := walletdb.Create(
"bdb", s.cfg.Datadir+"/neutrino.db", true, 60*time.Second,
)
if err != nil {
return err
}
netParams := s.cfg.chainParams()
config := neutrino.Config{
DataDir: s.cfg.Datadir,
ChainParams: *netParams,
Database: db,
}
if len(initialPeer) > 0 {
config.AddPeers = []string{initialPeer}
}
neutrino.UseLogger(logger("neutrino"))
btcwallet.UseLogger(logger("btcwallet"))
neutrinoSvc, err := neutrino.NewChainService(config)
if err != nil {
return err
}
if err := neutrinoSvc.Start(); err != nil {
return err
}
// wait for neutrino to sync
for !neutrinoSvc.IsCurrent() {
time.Sleep(1 * time.Second)
}
chainSrc := chain.NewNeutrinoClient(netParams, neutrinoSvc)
scanner := chain.NewNeutrinoClient(netParams, neutrinoSvc)
if err := withChainSource(chainSrc)(s); err != nil {
return err
}
return withScanner(scanner)(s)
}
}
// NewService creates the wallet service, an option must be set to configure the chain source.
func NewService(cfg WalletConfig, options ...WalletOption) (ports.WalletService, error) {
wallet.UseLogger(logger("wallet"))
svc := &service{
cfg: cfg,
esploraClient: &esploraClient{url: cfg.EsploraURL},
watchedScriptsLock: sync.RWMutex{},
watchedScripts: make(map[string]struct{}),
}
for _, option := range options {
if err := option(svc); err != nil {
return nil, err
}
}
opt := btcwallet.LoaderWithLocalWalletDB(cfg.Datadir, false, time.Minute)
config := btcwallet.Config{
LogDir: cfg.Datadir,
PrivatePass: cfg.Password,
PublicPass: cfg.Password,
Birthday: time.Now(),
RecoveryWindow: 0,
NetParams: cfg.chainParams(),
LoaderOptions: []btcwallet.LoaderOption{opt},
CoinSelectionStrategy: wallet.CoinSelectionLargest,
ChainSource: svc.chainSource,
}
blockCache := blockcache.NewBlockCache(20 * 1024 * 1024)
wallet, err := btcwallet.New(config, blockCache)
if err != nil {
return nil, fmt.Errorf("failed to setup wallet loader: %s", err)
}
if err := wallet.Start(); err != nil {
return nil, fmt.Errorf("failed to start wallet: %s", err)
}
svc.wallet = wallet
if err := svc.initWallet(); err != nil {
return nil, err
}
for {
if !wallet.InternalWallet().ChainSynced() {
log.Debug("waiting sync....")
time.Sleep(3 * time.Second)
continue
}
break
}
log.Debugf("chain synced")
return svc, nil
}
// setWalletLoader init the wallet db and configure the wallet accounts
func (s *service) initWallet() error {
w := s.wallet.InternalWallet()
walletAccounts, err := w.Accounts(p2wpkhKeyScope)
if err != nil {
return fmt.Errorf("failed to list wallet accounts: %s", err)
}
var mainAccountNumber, connectorAccountNumber, aspKeyAccountNumber uint32
if walletAccounts != nil {
for _, account := range walletAccounts.Accounts {
switch account.AccountName {
case string(mainAccount):
mainAccountNumber = account.AccountNumber
case string(connectorAccount):
connectorAccountNumber = account.AccountNumber
case string(aspKeyAccount):
aspKeyAccountNumber = account.AccountNumber
default:
continue
}
}
}
if mainAccountNumber == 0 && connectorAccountNumber == 0 && aspKeyAccountNumber == 0 {
log.Debug("creating default accounts for ark wallet...")
mainAccountNumber, err = w.NextAccount(p2wpkhKeyScope, string(mainAccount))
if err != nil {
return fmt.Errorf("failed to create %s: %s", mainAccount, err)
}
connectorAccountNumber, err = w.NextAccount(p2wpkhKeyScope, string(connectorAccount))
if err != nil {
return fmt.Errorf("failed to create %s: %s", connectorAccount, err)
}
aspKeyAccountNumber, err = w.NextAccount(p2trKeyScope, string(aspKeyAccount))
if err != nil {
return fmt.Errorf("failed to create %s: %s", aspKeyAccount, err)
}
}
log.Debugf("main account number: %d", mainAccountNumber)
log.Debugf("connector account number: %d", connectorAccountNumber)
log.Debugf("asp key account number: %d", aspKeyAccountNumber)
addrs, err := s.wallet.ListAddresses(string(aspKeyAccount), false)
if err != nil {
return err
}
if len(addrs) == 0 {
aspKeyAddr, err := s.wallet.NewAddress(lnwallet.TaprootPubkey, false, string(aspKeyAccount))
if err != nil {
return err
}
addrInfos, err := s.wallet.AddressInfo(aspKeyAddr)
if err != nil {
return err
}
managedAddr, ok := addrInfos.(waddrmgr.ManagedPubKeyAddress)
if !ok {
return errors.New("failed to cast address to managed pubkey address")
}
s.aspTaprootAddr = managedAddr
} else {
for info, addrs := range addrs {
if info.AccountName != string(aspKeyAccount) {
continue
}
for _, addr := range addrs {
fmt.Println(addr.DerivationPath)
if addr.Internal {
continue
}
splittedPath := strings.Split(addr.DerivationPath, "/")
last := splittedPath[len(splittedPath)-1]
if last == "0" {
decoded, err := btcutil.DecodeAddress(addr.Address, s.cfg.chainParams())
if err != nil {
return err
}
infos, err := s.wallet.AddressInfo(decoded)
if err != nil {
return err
}
managedPubkeyAddr, ok := infos.(waddrmgr.ManagedPubKeyAddress)
if !ok {
return errors.New("failed to cast address to managed pubkey address")
}
s.aspTaprootAddr = managedPubkeyAddr
break
}
}
}
}
return nil
}
func (s *service) Close() {
if err := s.wallet.Stop(); err != nil {
log.WithError(err).Warn("failed to gracefully stop the wallet, forcing shutdown")
}
}
func (s *service) BroadcastTransaction(ctx context.Context, txHex string) (string, error) {
if err := s.esploraClient.broadcast(txHex); err != nil {
return "", err
}
var tx wire.MsgTx
if err := tx.Deserialize(hex.NewDecoder(strings.NewReader(txHex))); err != nil {
return "", err
}
if err := s.wallet.PublishTransaction(&tx, ""); err != nil {
return "", err
}
return tx.TxHash().String(), nil
}
func (s *service) ConnectorsAccountBalance(ctx context.Context) (uint64, uint64, error) {
amount, err := s.getBalance(connectorAccount)
if err != nil {
return 0, 0, err
}
return amount, 0, nil
}
func (s *service) MainAccountBalance(ctx context.Context) (uint64, uint64, error) {
amount, err := s.getBalance(mainAccount)
if err != nil {
return 0, 0, err
}
return amount, 0, nil
}
func (s *service) DeriveAddresses(ctx context.Context, num int) ([]string, error) {
addresses := make([]string, 0, num)
for i := 0; i < num; i++ {
addr, err := s.deriveNextAddress(mainAccount)
if err != nil {
return nil, err
}
addresses = append(addresses, addr.EncodeAddress())
}
if len(addresses) == 0 {
return nil, errors.New("no addresses derived")
}
return addresses, nil
}
func (s *service) DeriveConnectorAddress(ctx context.Context) (string, error) {
addr, err := s.deriveNextAddress(connectorAccount)
if err != nil {
return "", err
}
return addr.EncodeAddress(), nil
}
func (s *service) GetPubkey(ctx context.Context) (*secp256k1.PublicKey, error) {
return s.aspTaprootAddr.PubKey(), nil
}
func (s *service) ListConnectorUtxos(ctx context.Context, connectorAddress string) ([]ports.TxInput, error) {
w := s.wallet.InternalWallet()
addr, err := btcutil.DecodeAddress(connectorAddress, w.ChainParams())
if err != nil {
return nil, err
}
script, err := txscript.PayToAddrScript(addr)
if err != nil {
return nil, err
}
connectorAccountNumber, err := w.AccountNumber(p2wpkhKeyScope, string(connectorAccount))
if err != nil {
return nil, err
}
utxos, err := w.UnspentOutputs(wallet.OutputSelectionPolicy{
Account: connectorAccountNumber,
RequiredConfirmations: 0,
})
if err != nil {
return nil, err
}
txInputs := make([]ports.TxInput, 0, len(utxos))
for _, utxo := range utxos {
if !bytes.Equal(utxo.Output.PkScript, script) {
continue
}
txInputs = append(txInputs, transactionOutputTxInput{utxo})
}
return txInputs, nil
}
func (s *service) LockConnectorUtxos(ctx context.Context, utxos []ports.TxOutpoint) error {
w := s.wallet.InternalWallet()
for _, utxo := range utxos {
id, _ := chainhash.NewHashFromStr(utxo.GetTxid())
if _, err := w.LeaseOutput(
wtxmgr.LockID(id[:]),
wire.OutPoint{
Hash: *id,
Index: utxo.GetIndex(),
},
outputLockDuration,
); err != nil {
return err
}
}
return nil
}
func (s *service) SelectUtxos(ctx context.Context, _ string, amount uint64) ([]ports.TxInput, uint64, error) {
w := s.wallet.InternalWallet()
mainAccountNumber, err := w.AccountNumber(p2wpkhKeyScope, string(mainAccount))
if err != nil {
return nil, 0, err
}
utxos, err := w.UnspentOutputs(wallet.OutputSelectionPolicy{
Account: mainAccountNumber,
RequiredConfirmations: 0, // allow uncomfirmed utxos
})
if err != nil {
return nil, 0, err
}
coins := make([]wallet.Coin, 0, len(utxos))
for _, utxo := range utxos {
coins = append(coins, wallet.Coin{
OutPoint: *wire.NewOutPoint(&utxo.OutPoint.Hash, utxo.OutPoint.Index),
TxOut: utxo.Output,
})
}
arranged, err := wallet.CoinSelectionLargest.ArrangeCoins(
coins,
btcutil.Amount(0), // unused by CoinSelectionLargest strategy
)
if err != nil {
return nil, 0, err
}
selectedAmount := uint64(0)
selectedUtxos := make([]ports.TxInput, 0, len(arranged))
for _, coin := range arranged {
if selectedAmount >= amount {
break
}
selectedAmount += uint64(coin.Value)
selectedUtxos = append(selectedUtxos, coinTxInput{coin})
}
change := selectedAmount - amount
return selectedUtxos, change, nil
}
func (s *service) SignTransaction(ctx context.Context, partialTx string, extractRawTx bool) (string, error) {
ptx, err := psbt.NewFromRawBytes(
strings.NewReader(partialTx),
true,
)
if err != nil {
return "", err
}
signedInputs, err := s.signPsbt(ptx)
if err != nil {
return "", err
}
if extractRawTx {
// verify that all inputs are signed
if len(signedInputs) != len(ptx.Inputs) {
return "", errors.New("not all inputs are signed, unable to finalize the psbt")
}
if err := psbt.MaybeFinalizeAll(ptx); err != nil {
return "", err
}
extracted, err := psbt.Extract(ptx)
if err != nil {
return "", err
}
var buf bytes.Buffer
if err := extracted.Serialize(&buf); err != nil {
return "", err
}
return hex.EncodeToString(buf.Bytes()), nil
}
return ptx.B64Encode()
}
func (s *service) SignTransactionTapscript(ctx context.Context, partialTx string, inputIndexes []int) (string, error) {
partial, err := psbt.NewFromRawBytes(
strings.NewReader(partialTx),
true,
)
if err != nil {
return "", err
}
if len(inputIndexes) == 0 {
inputIndexes = make([]int, len(partial.Inputs))
for i := range partial.Inputs {
inputIndexes[i] = i
}
}
signedInputs, err := s.signPsbt(partial)
if err != nil {
return "", err
}
for _, index := range inputIndexes {
hasBeenSigned := false
for _, signedIndex := range signedInputs {
if signedIndex == uint32(index) {
hasBeenSigned = true
break
}
}
if !hasBeenSigned {
return "", fmt.Errorf("input %d has not been signed", index)
}
}
return partial.B64Encode()
}
func (s *service) Status(ctx context.Context) (ports.WalletStatus, error) {
w := s.wallet.InternalWallet()
return status{
true,
true,
w.ChainSynced(),
}, nil
}
func (s *service) WaitForSync(ctx context.Context, txid string) error {
w := s.wallet.InternalWallet()
txhash, err := chainhash.NewHashFromStr(txid)
if err != nil {
return err
}
ticker := time.NewTicker(5 * time.Second)
for {
select {
case <-ctx.Done():
return ctx.Err()
case <-ticker.C:
_, err := w.GetTransaction(*txhash)
if err != nil {
if strings.Contains(err.Error(), wallet.ErrNoTx.Error()) {
continue
}
return err
} else {
ticker.Stop()
return nil
}
}
}
}
func (s *service) EstimateFees(ctx context.Context, partialTx string) (uint64, error) {
feeRate, err := s.esploraClient.getFeeRate()
if err != nil {
return 0, err
}
partial, err := psbt.NewFromRawBytes(
strings.NewReader(partialTx),
true,
)
if err != nil {
return 0, err
}
fee := feeRate * btcutil.Amount(partial.UnsignedTx.SerializeSize())
return uint64(fee.ToUnit(btcutil.AmountSatoshi)), nil
}
func (s *service) WatchScripts(ctx context.Context, scripts []string) error {
addresses := make([]btcutil.Address, 0, len(scripts))
for _, script := range scripts {
scriptBytes, err := hex.DecodeString(script)
if err != nil {
return err
}
addr, err := fromOutputScript(scriptBytes, s.cfg.chainParams())
if err != nil {
return err
}
addresses = append(addresses, addr)
}
if err := s.scanner.NotifyReceived(addresses); err != nil {
if err := s.UnwatchScripts(ctx, scripts); err != nil {
return fmt.Errorf("error while unwatching scripts: %w", err)
}
return err
}
s.watchedScriptsLock.Lock()
defer s.watchedScriptsLock.Unlock()
for _, script := range scripts {
s.watchedScripts[script] = struct{}{}
}
return nil
}
func (s *service) UnwatchScripts(ctx context.Context, scripts []string) error {
s.watchedScriptsLock.Lock()
defer s.watchedScriptsLock.Unlock()
for _, script := range scripts {
delete(s.watchedScripts, script)
}
return nil
}
func (s *service) GetNotificationChannel(
ctx context.Context,
) <-chan map[string]ports.VtxoWithValue {
ch := make(chan map[string]ports.VtxoWithValue)
go func() {
for n := range s.scanner.Notifications() {
switch m := n.(type) {
case chain.RelevantTx:
notification := s.castNotification(m.TxRecord)
ch <- notification
case chain.FilteredBlockConnected:
for _, tx := range m.RelevantTxs {
notification := s.castNotification(tx)
ch <- notification
}
}
}
}()
return ch
}
func (s *service) IsTransactionConfirmed(
ctx context.Context, txid string,
) (isConfirmed bool, blocktime int64, err error) {
return s.esploraClient.getTxStatus(txid)
}
func (s *service) castNotification(tx *wtxmgr.TxRecord) map[string]ports.VtxoWithValue {
vtxos := make(map[string]ports.VtxoWithValue)
s.watchedScriptsLock.RLock()
defer s.watchedScriptsLock.RUnlock()
for outputIndex, txout := range tx.MsgTx.TxOut {
script := hex.EncodeToString(txout.PkScript)
if _, ok := s.watchedScripts[script]; !ok {
continue
}
vtxos[script] = ports.VtxoWithValue{
VtxoKey: domain.VtxoKey{
Txid: tx.Hash.String(),
VOut: uint32(outputIndex),
},
Value: uint64(txout.Value),
}
}
return vtxos
}
func (s *service) getBalance(account accountName) (uint64, error) {
balance, err := s.wallet.ConfirmedBalance(0, string(account))
if err != nil {
return 0, err
}
return uint64(balance), nil
}
// this only supports deriving segwit v0 accounts
func (s *service) deriveNextAddress(account accountName) (btcutil.Address, error) {
return s.wallet.NewAddress(lnwallet.WitnessPubKey, false, string(account))
}
func withChainSource(chainSource chain.Interface) WalletOption {
return func(s *service) error {
if s.chainSource != nil {
return errors.New("chain source already set")
}
s.chainSource = chainSource
return nil
}
}
func withScanner(chainSource chain.Interface) WalletOption {
return func(s *service) error {
if s.scanner != nil {
return errors.New("scanner already set")
}
if err := chainSource.Start(); err != nil {
return fmt.Errorf("failed to start scanner: %s", err)
}
s.scanner = chainSource
return nil
}
}
// status implements ports.WalletStatus interface
type status struct {
initialized bool
unlocked bool
synced bool
}
func (s status) IsInitialized() bool {
return s.initialized
}
func (s status) IsUnlocked() bool {
return s.unlocked
}
func (s status) IsSynced() bool {
return s.synced
}
func fromOutputScript(script []byte, netParams *chaincfg.Params) (btcutil.Address, error) {
return btcutil.NewAddressTaproot(script[2:], netParams)
}
func logger(subsystem string) btclog.Logger {
return btclog.NewBackend(log.StandardLogger().Writer()).Logger(subsystem)
}

View File

@@ -21,7 +21,7 @@ const (
zero32 = "0000000000000000000000000000000000000000000000000000000000000000"
)
func (s *service) SignPset(
func (s *service) SignTransaction(
ctx context.Context, pset string, extractRawTx bool,
) (string, error) {
res, err := s.txClient.SignPset(ctx, &pb.SignPsetRequest{
@@ -91,7 +91,7 @@ func (s *service) BroadcastTransaction(
)
if err != nil {
if strings.Contains(err.Error(), "non-BIP68-final") {
return "", fmt.Errorf("non-BIP68-final")
return "", ports.ErrNonFinalBIP68
}
return "", err
@@ -127,7 +127,7 @@ func (s *service) WaitForSync(ctx context.Context, txid string) error {
return nil
}
func (s *service) SignPsetWithKey(ctx context.Context, b64 string, indexes []int) (string, error) {
func (s *service) SignTransactionTapscript(ctx context.Context, b64 string, indexes []int) (string, error) {
pset, err := psetv2.NewPsetFromBase64(b64)
if err != nil {
return "", err

View File

@@ -114,6 +114,28 @@ func (a *adminHandler) GetScheduledSweep(ctx context.Context, _ *arkv1.GetSchedu
return &arkv1.GetScheduledSweepResponse{Sweeps: sweeps}, nil
}
func (a *adminHandler) GetWalletAddress(ctx context.Context, _ *arkv1.GetWalletAddressRequest) (*arkv1.GetWalletAddressResponse, error) {
addr, err := a.adminService.GetWalletAddress(ctx)
if err != nil {
return nil, err
}
return &arkv1.GetWalletAddressResponse{Address: addr}, nil
}
func (a *adminHandler) GetWalletStatus(ctx context.Context, _ *arkv1.GetWalletStatusRequest) (*arkv1.GetWalletStatusResponse, error) {
status, err := a.adminService.GetWalletStatus(ctx)
if err != nil {
return nil, err
}
return &arkv1.GetWalletStatusResponse{
Initialized: status.IsInitialized,
Unlocked: status.IsUnlocked,
Synced: status.IsSynced,
}, nil
}
// convert sats to string BTC
func convertSatoshis(sats uint64) string {
btc := float64(sats) * 1e-8

View File

@@ -8,19 +8,18 @@ import (
"github.com/ark-network/ark/common"
"github.com/ark-network/ark/internal/core/domain"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/vulpemventures/go-elements/address"
"github.com/vulpemventures/go-elements/psetv2"
)
func parseTxs(txs []string) ([]string, error) {
if len(txs) <= 0 {
return nil, fmt.Errorf("missing list of forfeit txs")
}
for _, tx := range txs {
if _, err := psetv2.NewPsetFromBase64(tx); err != nil {
return nil, fmt.Errorf("invalid tx format")
}
}
// TODO abstract this ?
// for _, tx := range txs {
// if _, err := psetv2.NewPsetFromBase64(tx); err != nil {
// return nil, fmt.Errorf("invalid tx format")
// }
// }
return txs, nil
}
@@ -43,12 +42,6 @@ func parseReceivers(outs []*arkv1.Output) ([]domain.Receiver, error) {
var pubkey, addr string
_, pk, _, err := common.DecodeAddress(out.GetAddress())
if err != nil {
if _, err := address.ToOutputScript(out.GetAddress()); err != nil {
return nil, fmt.Errorf("invalid output address: unknown format")
}
if isConf, _ := address.IsConfidential(out.GetAddress()); isConf {
return nil, fmt.Errorf("invalid output address: must be unconfidential")
}
addr = out.GetAddress()
}
if pk != nil {

View File

@@ -1,4 +1,4 @@
package e2e
package e2e_test
import (
"encoding/json"
@@ -8,16 +8,17 @@ import (
"time"
"github.com/ark-network/ark/common"
utils "github.com/ark-network/ark/test/e2e"
"github.com/stretchr/testify/require"
)
const (
composePath = "../../../docker-compose.regtest.yml"
composePath = "../../../../docker-compose.regtest.yml"
ONE_BTC = 1_0000_0000
)
func TestMain(m *testing.M) {
_, err := runCommand("docker-compose", "-f", composePath, "up", "-d", "--build")
_, err := utils.RunCommand("docker-compose", "-f", composePath, "up", "-d", "--build")
if err != nil {
fmt.Printf("error starting docker-compose: %s", err)
os.Exit(1)
@@ -29,13 +30,13 @@ func TestMain(m *testing.M) {
os.Exit(1)
}
_, err = runOceanCommand("wallet", "create", "--password", password)
_, err = runOceanCommand("wallet", "create", "--password", utils.Password)
if err != nil {
fmt.Printf("error creating ocean wallet: %s", err)
os.Exit(1)
}
_, err = runOceanCommand("wallet", "unlock", "--password", password)
_, err = runOceanCommand("wallet", "unlock", "--password", utils.Password)
if err != nil {
fmt.Printf("error unlocking ocean wallet: %s", err)
os.Exit(1)
@@ -62,13 +63,25 @@ func TestMain(m *testing.M) {
os.Exit(1)
}
_, err = runCommand("nigiri", "faucet", "--liquid", addr.Addresses[0])
_, err = utils.RunCommand("nigiri", "faucet", "--liquid", addr.Addresses[0])
if err != nil {
fmt.Printf("error funding ocean account: %s", err)
os.Exit(1)
}
_, err = runCommand("nigiri", "faucet", "--liquid", addr.Addresses[0])
_, err = utils.RunCommand("nigiri", "faucet", "--liquid", addr.Addresses[0])
if err != nil {
fmt.Printf("error funding ocean account: %s", err)
os.Exit(1)
}
_, err = utils.RunCommand("nigiri", "faucet", "--liquid", addr.Addresses[0])
if err != nil {
fmt.Printf("error funding ocean account: %s", err)
os.Exit(1)
}
_, err = utils.RunCommand("nigiri", "faucet", "--liquid", addr.Addresses[0])
if err != nil {
fmt.Printf("error funding ocean account: %s", err)
os.Exit(1)
@@ -76,13 +89,13 @@ func TestMain(m *testing.M) {
time.Sleep(3 * time.Second)
_, err = runArkCommand("init", "--ark-url", "localhost:6000", "--password", password, "--network", common.LiquidRegTest.Name, "--explorer", "http://chopsticks-liquid:3000")
_, err = runArkCommand("init", "--ark-url", "localhost:6000", "--password", utils.Password, "--network", common.LiquidRegTest.Name, "--explorer", "http://chopsticks-liquid:3000")
if err != nil {
fmt.Printf("error initializing ark config: %s", err)
os.Exit(1)
}
var receive arkReceive
var receive utils.ArkReceive
receiveStr, err := runArkCommand("receive")
if err != nil {
fmt.Printf("error getting ark receive addresses: %s", err)
@@ -94,7 +107,7 @@ func TestMain(m *testing.M) {
os.Exit(1)
}
_, err = runCommand("nigiri", "faucet", "--liquid", receive.Onchain)
_, err = utils.RunCommand("nigiri", "faucet", "--liquid", receive.Onchain)
if err != nil {
fmt.Printf("error funding ark account: %s", err)
os.Exit(1)
@@ -104,7 +117,7 @@ func TestMain(m *testing.M) {
code := m.Run()
_, err = runCommand("docker-compose", "-f", composePath, "down")
_, err = utils.RunCommand("docker-compose", "-f", composePath, "down")
if err != nil {
fmt.Printf("error stopping docker-compose: %s", err)
os.Exit(1)
@@ -113,16 +126,16 @@ func TestMain(m *testing.M) {
}
func TestOnboard(t *testing.T) {
var balance arkBalance
var balance utils.ArkBalance
balanceStr, err := runArkCommand("balance")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(balanceStr), &balance))
balanceBefore := balance.Offchain.Total
_, err = runArkCommand("onboard", "--amount", "1000", "--password", password)
_, err = runArkCommand("onboard", "--amount", "1000", "--password", utils.Password)
require.NoError(t, err)
err = generateBlock()
err = utils.GenerateBlock()
require.NoError(t, err)
balanceStr, err = runArkCommand("balance")
@@ -133,23 +146,23 @@ func TestOnboard(t *testing.T) {
}
func TestTrustedOnboard(t *testing.T) {
var balance arkBalance
var balance utils.ArkBalance
balanceStr, err := runArkCommand("balance")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(balanceStr), &balance))
balanceBefore := balance.Offchain.Total
onboardStr, err := runArkCommand("onboard", "--trusted", "--password", password)
onboardStr, err := runArkCommand("onboard", "--trusted", "--password", utils.Password)
require.NoError(t, err)
var result arkTrustedOnboard
var result utils.ArkTrustedOnboard
require.NoError(t, json.Unmarshal([]byte(onboardStr), &result))
_, err = runCommand("nigiri", "faucet", "--liquid", result.OnboardAddress)
_, err = utils.RunCommand("nigiri", "faucet", "--liquid", result.OnboardAddress)
require.NoError(t, err)
_, err = runCommand("nigiri", "faucet", "--liquid", result.OnboardAddress)
_, err = utils.RunCommand("nigiri", "faucet", "--liquid", result.OnboardAddress)
require.NoError(t, err)
time.Sleep(5 * time.Second)
@@ -162,20 +175,20 @@ func TestTrustedOnboard(t *testing.T) {
}
func TestSendOffchain(t *testing.T) {
_, err := runArkCommand("onboard", "--amount", "1000", "--password", password)
_, err := runArkCommand("onboard", "--amount", "1000", "--password", utils.Password)
require.NoError(t, err)
err = generateBlock()
err = utils.GenerateBlock()
require.NoError(t, err)
var receive arkReceive
var receive utils.ArkReceive
receiveStr, err := runArkCommand("receive")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(receiveStr), &receive))
_, err = runArkCommand("send", "--amount", "1000", "--to", receive.Offchain, "--password", password)
_, err = runArkCommand("send", "--amount", "1000", "--to", receive.Offchain, "--password", utils.Password)
require.NoError(t, err)
var balance arkBalance
var balance utils.ArkBalance
balanceStr, err := runArkCommand("balance")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(balanceStr), &balance))
@@ -183,22 +196,22 @@ func TestSendOffchain(t *testing.T) {
}
func TestUnilateralExit(t *testing.T) {
_, err := runArkCommand("onboard", "--amount", "1000", "--password", password)
_, err := runArkCommand("onboard", "--amount", "1000", "--password", utils.Password)
require.NoError(t, err)
err = generateBlock()
err = utils.GenerateBlock()
require.NoError(t, err)
var balance arkBalance
var balance utils.ArkBalance
balanceStr, err := runArkCommand("balance")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(balanceStr), &balance))
require.NotZero(t, balance.Offchain.Total)
require.Len(t, balance.Onchain.Locked, 0)
_, err = runArkCommand("redeem", "--force", "--password", password)
_, err = runArkCommand("redeem", "--force", "--password", utils.Password)
require.NoError(t, err)
err = generateBlock()
err = utils.GenerateBlock()
require.NoError(t, err)
balanceStr, err = runArkCommand("balance")
@@ -212,17 +225,17 @@ func TestUnilateralExit(t *testing.T) {
}
func TestCollaborativeExit(t *testing.T) {
_, err := runArkCommand("onboard", "--amount", "1000", "--password", password)
_, err := runArkCommand("onboard", "--amount", "1000", "--password", utils.Password)
require.NoError(t, err)
err = generateBlock()
err = utils.GenerateBlock()
require.NoError(t, err)
var receive arkReceive
var receive utils.ArkReceive
receiveStr, err := runArkCommand("receive")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(receiveStr), &receive))
var balance arkBalance
var balance utils.ArkBalance
balanceStr, err := runArkCommand("balance")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(balanceStr), &balance))
@@ -230,7 +243,7 @@ func TestCollaborativeExit(t *testing.T) {
balanceBefore := balance.Offchain.Total
balanceOnchainBefore := balance.Onchain.Spendable
_, err = runArkCommand("redeem", "--amount", "1000", "--address", receive.Onchain, "--password", password)
_, err = runArkCommand("redeem", "--amount", "1000", "--address", receive.Onchain, "--password", utils.Password)
require.NoError(t, err)
time.Sleep(5 * time.Second)
@@ -242,3 +255,13 @@ func TestCollaborativeExit(t *testing.T) {
require.Equal(t, balanceBefore-1000, balance.Offchain.Total)
require.Equal(t, balanceOnchainBefore+1000, balance.Onchain.Spendable)
}
func runOceanCommand(arg ...string) (string, error) {
args := append([]string{"exec", "oceand", "ocean"}, arg...)
return utils.RunCommand("docker", args...)
}
func runArkCommand(arg ...string) (string, error) {
args := append([]string{"exec", "-t", "arkd", "ark"}, arg...)
return utils.RunCommand("docker", args...)
}

View File

@@ -0,0 +1,212 @@
package e2e_test
import (
"encoding/json"
"fmt"
"net/http"
"os"
"testing"
"time"
utils "github.com/ark-network/ark/test/e2e"
"github.com/stretchr/testify/require"
)
const (
composePath = "../../../../docker-compose.clark.regtest.yml"
ONE_BTC = 1_0000_0000
)
func TestMain(m *testing.M) {
_, err := utils.RunCommand("docker-compose", "-f", composePath, "up", "-d", "--build")
if err != nil {
fmt.Printf("error starting docker-compose: %s", err)
os.Exit(1)
}
// wait some time to let the wallet start
time.Sleep(12 * time.Second)
req, err := http.NewRequest("GET", "http://localhost:6000/v1/admin/address", nil)
if err != nil {
fmt.Printf("error requesting wallet address: %s", err)
os.Exit(1)
}
req.Header.Set("Authorization", "Basic YWRtaW46YWRtaW4=")
adminHttpClient := &http.Client{
Timeout: 15 * time.Second,
}
resp, err := adminHttpClient.Do(req)
if err != nil {
fmt.Printf("error requesting wallet address: %s", err)
os.Exit(1)
}
var addr struct {
Address string `json:"address"`
}
if err := json.NewDecoder(resp.Body).Decode(&addr); err != nil {
fmt.Printf("error unmarshalling /address response: %s", err)
os.Exit(1)
}
_, err = utils.RunCommand("nigiri", "faucet", addr.Address)
if err != nil {
fmt.Printf("error funding ASP account: %s", err)
os.Exit(1)
}
_, err = utils.RunCommand("nigiri", "faucet", addr.Address)
if err != nil {
fmt.Printf("error funding ASP account: %s", err)
os.Exit(1)
}
time.Sleep(3 * time.Second)
_, err = runClarkCommand("init", "--ark-url", "localhost:6000", "--password", utils.Password, "--network", "regtest", "--explorer", "http://chopsticks:3000")
if err != nil {
fmt.Printf("error initializing ark config: %s", err)
os.Exit(1)
}
var receive utils.ArkReceive
receiveStr, err := runClarkCommand("receive")
if err != nil {
fmt.Printf("error getting ark receive addresses: %s", err)
os.Exit(1)
}
if err := json.Unmarshal([]byte(receiveStr), &receive); err != nil {
fmt.Printf("error unmarshalling ark receive addresses: %s", err)
os.Exit(1)
}
_, err = utils.RunCommand("nigiri", "faucet", receive.Onchain)
if err != nil {
fmt.Printf("error funding ark account: %s", err)
os.Exit(1)
}
time.Sleep(5 * time.Second)
code := m.Run()
_, err = utils.RunCommand("docker-compose", "-f", composePath, "down")
if err != nil {
fmt.Printf("error stopping docker-compose: %s", err)
os.Exit(1)
}
os.Exit(code)
}
func TestOnboard(t *testing.T) {
var balance utils.ArkBalance
balanceStr, err := runClarkCommand("balance")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(balanceStr), &balance))
balanceBefore := balance.Offchain.Total
_, err = runClarkCommand("onboard", "--amount", "1000", "--password", utils.Password)
require.NoError(t, err)
err = utils.GenerateBlock()
require.NoError(t, err)
balanceStr, err = runClarkCommand("balance")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(balanceStr), &balance))
require.Equal(t, balanceBefore+1000, balance.Offchain.Total)
}
func TestSendOffchain(t *testing.T) {
_, err := runClarkCommand("onboard", "--amount", "1000", "--password", utils.Password)
require.NoError(t, err)
err = utils.GenerateBlock()
require.NoError(t, err)
var receive utils.ArkReceive
receiveStr, err := runClarkCommand("receive")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(receiveStr), &receive))
_, err = runClarkCommand("send", "--amount", "1000", "--to", receive.Offchain, "--password", utils.Password)
require.NoError(t, err)
var balance utils.ArkBalance
balanceStr, err := runClarkCommand("balance")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(balanceStr), &balance))
require.NotZero(t, balance.Offchain.Total)
}
func TestUnilateralExit(t *testing.T) {
_, err := runClarkCommand("onboard", "--amount", "1000", "--password", utils.Password)
require.NoError(t, err)
err = utils.GenerateBlock()
require.NoError(t, err)
var balance utils.ArkBalance
balanceStr, err := runClarkCommand("balance")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(balanceStr), &balance))
require.NotZero(t, balance.Offchain.Total)
require.Len(t, balance.Onchain.Locked, 0)
_, err = runClarkCommand("redeem", "--force", "--password", utils.Password)
require.NoError(t, err)
err = utils.GenerateBlock()
require.NoError(t, err)
balanceStr, err = runClarkCommand("balance")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(balanceStr), &balance))
require.Zero(t, balance.Offchain.Total)
require.Greater(t, len(balance.Onchain.Locked), 0)
lockedBalance := balance.Onchain.Locked[0].Amount
require.NotZero(t, lockedBalance)
}
func TestCollaborativeExit(t *testing.T) {
_, err := runClarkCommand("onboard", "--amount", "1000", "--password", utils.Password)
require.NoError(t, err)
err = utils.GenerateBlock()
require.NoError(t, err)
var receive utils.ArkReceive
receiveStr, err := runClarkCommand("receive")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(receiveStr), &receive))
var balance utils.ArkBalance
balanceStr, err := runClarkCommand("balance")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(balanceStr), &balance))
balanceBefore := balance.Offchain.Total
balanceOnchainBefore := balance.Onchain.Spendable
_, err = runClarkCommand("redeem", "--amount", "1000", "--address", receive.Onchain, "--password", utils.Password)
require.NoError(t, err)
time.Sleep(5 * time.Second)
balanceStr, err = runClarkCommand("balance")
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(balanceStr), &balance))
require.Equal(t, balanceBefore-1000, balance.Offchain.Total)
require.Equal(t, balanceOnchainBefore+1000, balance.Onchain.Spendable)
}
func runClarkCommand(arg ...string) (string, error) {
args := append([]string{"exec", "-t", "clarkd", "ark"}, arg...)
return utils.RunCommand("docker", args...)
}

View File

@@ -10,10 +10,10 @@ import (
)
const (
password = "password"
Password = "password"
)
type arkBalance struct {
type ArkBalance struct {
Offchain struct {
Total int `json:"total"`
} `json:"offchain_balance"`
@@ -26,27 +26,17 @@ type arkBalance struct {
} `json:"onchain_balance"`
}
type arkReceive struct {
type ArkReceive struct {
Offchain string `json:"offchain_address"`
Onchain string `json:"onchain_address"`
}
type arkTrustedOnboard struct {
type ArkTrustedOnboard struct {
OnboardAddress string `json:"onboard_address"`
}
func runOceanCommand(arg ...string) (string, error) {
args := append([]string{"exec", "oceand", "ocean"}, arg...)
return runCommand("docker", args...)
}
func runArkCommand(arg ...string) (string, error) {
args := append([]string{"exec", "-t", "arkd", "ark"}, arg...)
return runCommand("docker", args...)
}
func generateBlock() error {
if _, err := runCommand("nigiri", "rpc", "--liquid", "generatetoaddress", "1", "el1qqwk722tghgkgmh3r2ph4d2apwj0dy9xnzlenzklx8jg3z299fpaw56trre9gpk6wmw0u4qycajqeva3t7lzp7wnacvwxha59r"); err != nil {
func GenerateBlock() error {
if _, err := RunCommand("nigiri", "rpc", "--liquid", "generatetoaddress", "1", "el1qqwk722tghgkgmh3r2ph4d2apwj0dy9xnzlenzklx8jg3z299fpaw56trre9gpk6wmw0u4qycajqeva3t7lzp7wnacvwxha59r"); err != nil {
return err
}
@@ -54,7 +44,7 @@ func generateBlock() error {
return nil
}
func runCommand(name string, arg ...string) (string, error) {
func RunCommand(name string, arg ...string) (string, error) {
errb := new(strings.Builder)
cmd := newCommand(name, arg...)