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 eaad553 commit afda75b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lwk/lwkwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (
type Satoshi = uint64

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

const (
minimumSatPerByte = 0.1
minimumSatPerByte float64 = 0.1
)

// LWKRpcWallet uses the elementsd rpc wallet
Expand Down Expand Up @@ -109,7 +109,7 @@ 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))
fundedTx, err := r.lwkClient.send(ctx, &sendRequest{
Expand Down Expand Up @@ -155,7 +155,7 @@ func (r *LWKRpcWallet) CreateAndBroadcastTransaction(swapParams *swap.OpeningPar
if err != nil {
return "", "", 0, err
}
return broadcasted.Txid, txhex, SatPerKVByte(feerate), nil
return broadcasted.Txid, txhex, 0, nil
}

// GetBalance returns the balance in sats
Expand Down Expand Up @@ -228,7 +228,7 @@ func (r *LWKRpcWallet) getFeePerKb(ctx context.Context) SatPerKVByte {
// convert to sat per byte
// 1 kb = 1000 bytes
var kb float64 = 1000
satPerByte := uint64(float64(feeBTCPerKb) * math.Pow10(int(8)) / kb)
satPerByte := float64(feeBTCPerKb) * math.Pow10(int(8)) / kb
if satPerByte < minimumSatPerByte {
satPerByte = minimumSatPerByte
}
Expand All @@ -241,8 +241,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

0 comments on commit afda75b

Please sign in to comment.