Skip to content

Commit

Permalink
Fix btc wallet restore (covenantless asp) (#332)
Browse files Browse the repository at this point in the history
* first account = default btcwallet account (account index 0)

* Update server/internal/infrastructure/wallet/btc-embedded/wallet.go

Co-authored-by: Pietralberto Mazza <[email protected]>
Signed-off-by: Louis Singer <[email protected]>

* fix restoration

* increase arkd timeout

* fix connector signature

---------

Signed-off-by: Louis Singer <[email protected]>
Co-authored-by: Pietralberto Mazza <[email protected]>
  • Loading branch information
louisinger and altafan authored Sep 27, 2024
1 parent ab6ae36 commit 72e31d8
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 102 deletions.
6 changes: 3 additions & 3 deletions common/fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ var TreeTxSize = (&input.TxWeightEstimator{}).
var CovenantTreeTxSize = TreeTxSize * 2

var ConnectorTxSize = (&input.TxWeightEstimator{}).
AddP2WKHInput().
AddP2WKHOutput().
AddP2WKHOutput().
AddTaprootKeySpendInput(txscript.SigHashDefault).
AddP2TROutput().
AddP2TROutput().
VSize()

func ComputeForfeitMinRelayFee(
Expand Down
10 changes: 6 additions & 4 deletions server/cmd/arkd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ var (
}
)

var timeout = time.Minute

func walletStatusAction(ctx *cli.Context) error {
baseURL := ctx.String("url")
tlsCertPath := ctx.String("tls-cert-path")
Expand Down Expand Up @@ -220,7 +222,7 @@ func post[T any](url, body, key, macaroon, tlsCert string) (result T, err error)
req.Header.Add("X-Macaroon", macaroon)
}
client := &http.Client{
Timeout: 30 * time.Second,
Timeout: timeout,
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
},
Expand Down Expand Up @@ -267,7 +269,7 @@ func get[T any](url, key, macaroon, tlsCert string) (result T, err error) {
}

client := &http.Client{
Timeout: 30 * time.Second,
Timeout: timeout,
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
},
Expand Down Expand Up @@ -331,7 +333,7 @@ func getBalance(url, macaroon, tlsCert string) (*balance, error) {
req.Header.Add("X-Macaroon", macaroon)
}
client := &http.Client{
Timeout: 30 * time.Second,
Timeout: timeout,
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
},
Expand Down Expand Up @@ -384,7 +386,7 @@ func getStatus(url, tlsCert string) (*status, error) {
req.Header.Add("Content-Type", "application/json")

client := &http.Client{
Timeout: 30 * time.Second,
Timeout: timeout,
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
},
Expand Down
9 changes: 3 additions & 6 deletions server/internal/infrastructure/wallet/btc-embedded/psbt.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,11 @@ func (s *service) signPsbt(packet *psbt.Packet, inputsToSign []int) ([]uint32, e
}

var managedAddress waddrmgr.ManagedPubKeyAddress
var isTaproot bool
isTaproot := txscript.IsPayToTaproot(in.WitnessUtxo.PkScript)

if len(in.TaprootLeafScript) > 0 && txscript.IsPayToTaproot(in.WitnessUtxo.PkScript) {
// segwit v1
isTaproot = true
managedAddress = s.aspTaprootAddr
if len(in.TaprootLeafScript) > 0 {
managedAddress = s.aspKeyAddr
} else {
// segwit v0
var err error
managedAddress, _, _, err = s.wallet.ScriptForOutput(in.WitnessUtxo)
if err != nil {
Expand Down
Loading

0 comments on commit 72e31d8

Please sign in to comment.