Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make lwk available #288

Merged
merged 29 commits into from
Jul 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ae9ae99
txwatcher: delete deadcode
YusukeShimizu Mar 26, 2024
0735dab
multi: refactor interfaces onchain wallet
YusukeShimizu Mar 26, 2024
c1dd008
lwk: lwk package
YusukeShimizu Mar 26, 2024
baaf69d
lwk: txwatcher
YusukeShimizu Mar 26, 2024
ab80a53
multi: lwk configuration support for Liquid swaps
YusukeShimizu Mar 26, 2024
ff46495
test: add integration test for LWK
YusukeShimizu Mar 26, 2024
8ad9a7a
doc: add LWK setup guide
YusukeShimizu Mar 26, 2024
cdd89ea
nix: add lwk and blockstream-electrs packages
YusukeShimizu May 1, 2024
3fe81f6
wip: claim_coop case
YusukeShimizu May 2, 2024
383a143
txwather: wait for initial block header sub
YusukeShimizu May 10, 2024
381daa1
lwk: add TLS support for Electrum
YusukeShimizu May 13, 2024
1041bed
test: add integration test for LWK and liquid
YusukeShimizu May 23, 2024
58c516c
lwk: check if the version is supported
YusukeShimizu May 26, 2024
53e56fd
config: make lwk-related settings clear
YusukeShimizu May 29, 2024
83603a2
config: include LWK configuration in the output
YusukeShimizu May 30, 2024
d1f6a89
lwk: ensure thread safety
YusukeShimizu May 30, 2024
f2ee818
electrum: proper log output of tx watcher
YusukeShimizu May 31, 2024
3d45569
clightning: add LWK configuration options
YusukeShimizu Jun 6, 2024
aa9550b
cln+lnd: liveness check
YusukeShimizu Jun 12, 2024
1d98fe2
lwk: set prime seconds
YusukeShimizu Jun 12, 2024
cd24c35
cln+lnd: liveness check on swapout
YusukeShimizu Jun 16, 2024
2a3b3f4
test: add tests for backend down
YusukeShimizu Jun 19, 2024
8ed026d
nix: update pinned nixpkgs revision
YusukeShimizu Jun 20, 2024
6c6c802
electrum: ensure client is properly reinitialized
YusukeShimizu Jun 26, 2024
c4e9145
swap: add exponential backoff and jitter mechanism
YusukeShimizu Jun 26, 2024
22f4e66
swap: add missing Event_OnTimeout transition
YusukeShimizu Jun 26, 2024
45fb414
multi: using nix flake and upgrading lwk
YusukeShimizu Jun 29, 2024
7045055
lwkwallet: refactor fee calculations
YusukeShimizu Jun 29, 2024
66fead0
lwkwallet: implement SetLabel method
YusukeShimizu Jul 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions lwk/lwkwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import (
type Satoshi = uint64

// SatPerKVByte represents a fee rate in sat/kb.
type SatPerKVByte = uint64
type SatPerKVByte = float64

const (
minimumSatPerByte = 200
minimumSatPerByte SatPerKVByte = 0.1
nepet marked this conversation as resolved.
Show resolved Hide resolved
// 1 kb = 1000 bytes
kb float64 = 1000
)

// LWKRpcWallet uses the elementsd rpc wallet
Expand Down Expand Up @@ -108,9 +110,9 @@ func (r *LWKRpcWallet) createWallet(ctx context.Context, walletName, signerName

// CreateFundedTransaction takes a tx with outputs and adds inputs in order to spend the tx
func (r *LWKRpcWallet) CreateAndBroadcastTransaction(swapParams *swap.OpeningParams,
asset []byte) (txid, rawTx string, fee SatPerKVByte, err error) {
asset []byte) (txid, rawTx string, fee Satoshi, err error) {
ctx := context.Background()
feerate := float64(r.getFeePerKb(ctx))
feerate := float64(r.getFeePerKb(ctx)) * kb
fundedTx, err := r.lwkClient.send(ctx, &sendRequest{
Addressees: []*unvalidatedAddressee{
{
Expand Down Expand Up @@ -212,8 +214,7 @@ func (r *LWKRpcWallet) SendRawTx(txHex string) (string, error) {

func (r *LWKRpcWallet) getFeePerKb(ctx context.Context) SatPerKVByte {
feeBTCPerKb, err := r.electrumClient.GetFee(ctx, wallet.LiquidTargetBlocks)
// convert to sat per byte
satPerByte := uint64(float64(feeBTCPerKb) * math.Pow10(int(8)))
satPerByte := float64(feeBTCPerKb) * math.Pow10(int(8)) / kb
if satPerByte < minimumSatPerByte {
satPerByte = minimumSatPerByte
}
Expand All @@ -226,8 +227,8 @@ func (r *LWKRpcWallet) getFeePerKb(ctx context.Context) SatPerKVByte {
func (r *LWKRpcWallet) GetFee(txSize int64) (Satoshi, error) {
ctx := context.Background()
// assume largest witness
fee := r.getFeePerKb(ctx) * uint64(txSize)
return fee, nil
fee := r.getFeePerKb(ctx) * float64(txSize)
return Satoshi(fee), nil
}

func (r *LWKRpcWallet) SetLabel(txID, address, label string) error {
Expand Down