Skip to content

Commit

Permalink
fixup! lwk: lwk package
Browse files Browse the repository at this point in the history
  • Loading branch information
YusukeShimizu committed Mar 28, 2024
1 parent 4b7352d commit 0a84013
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lwk/lwkwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

const (
kiloByte = 1000
minimumSatPerByte = 0.1
minimumSatPerByte = 0.2
)

// LWKRpcWallet uses the elementsd rpc wallet
Expand Down Expand Up @@ -69,6 +69,14 @@ func (r *LWKRpcWallet) setupWallet() error {
func (r *LWKRpcWallet) CreateAndBroadcastTransaction(swapParams *swap.OpeningParams,
asset []byte) (txid, rawTx string, fee uint64, err error) {
ctx := context.Background()
feeRes, err := r.electrumClient.GetFee(ctx, wallet.LiquidTargetBlocks)
satPerByte := float64(feeRes) / float64(kiloByte)
if err != nil {
satPerByte = minimumSatPerByte
}
if satPerByte < minimumSatPerByte {
satPerByte = minimumSatPerByte
}
fundedTx, err := r.lwkClient.send(ctx, &sendRequest{
Addressees: []*unvalidatedAddressee{
{
Expand All @@ -77,6 +85,7 @@ func (r *LWKRpcWallet) CreateAndBroadcastTransaction(swapParams *swap.OpeningPar
},
},
WalletName: r.walletName,
FeeRate: &satPerByte,
})
if err != nil {
return "", "", 0, err
Expand Down

0 comments on commit 0a84013

Please sign in to comment.