Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
YusukeShimizu committed May 2, 2024
1 parent afda75b commit 48f67fd
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lwk/lwkwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ type Satoshi = uint64
type SatPerKVByte = float64

const (
minimumSatPerByte float64 = 0.1
minimumSatPerByte SatPerKVByte = 0.1
// 1 kb = 1000 bytes
kb float64 = 1000
)

// LWKRpcWallet uses the elementsd rpc wallet
Expand Down Expand Up @@ -111,7 +113,7 @@ func (r *LWKRpcWallet) createWallet(ctx context.Context, walletName, signerName
func (r *LWKRpcWallet) CreateAndBroadcastTransaction(swapParams *swap.OpeningParams,
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 @@ -225,9 +227,6 @@ 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
// 1 kb = 1000 bytes
var kb float64 = 1000
satPerByte := float64(feeBTCPerKb) * math.Pow10(int(8)) / kb
if satPerByte < minimumSatPerByte {
satPerByte = minimumSatPerByte
Expand Down

0 comments on commit 48f67fd

Please sign in to comment.