Skip to content

Commit 719b812

Browse files
committed
Merge branch 'satstring'
2 parents ff39b60 + 8c6b56f commit 719b812

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

backend/coins/btc/handlers/handlers.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"os"
2323
"path"
2424
"path/filepath"
25+
"strconv"
2526
"strings"
2627
"time"
2728

@@ -272,7 +273,7 @@ func (input *sendTxInput) UnmarshalJSON(jsonBytes []byte) error {
272273
SendAll string `json:"sendAll"`
273274
FeeTarget string `json:"feeTarget"`
274275
// Provided in Sat/vByte, will be converted to Sat/vKb.
275-
FeePerByte float64 `json:"feePerByte"`
276+
FeePerByte string `json:"feePerByte"`
276277
Amount string `json:"amount"`
277278
SelectedUTXOS []string `json:"selectedUTXOS"`
278279
Data string `json:"data"`
@@ -288,7 +289,13 @@ func (input *sendTxInput) UnmarshalJSON(jsonBytes []byte) error {
288289
if err != nil {
289290
return errp.WithMessage(err, "Failed to retrieve fee target code")
290291
}
291-
input.FeePerKb = btcutil.Amount(jsonBody.FeePerByte * 1000)
292+
if input.FeeTargetCode == accounts.FeeTargetCodeCustom {
293+
feePerKb, err := strconv.ParseFloat(jsonBody.FeePerByte, 64)
294+
if err != nil {
295+
return err
296+
}
297+
input.FeePerKb = btcutil.Amount(feePerKb * 1000)
298+
}
292299
if jsonBody.SendAll == "yes" {
293300
input.Amount = coin.NewSendAmountAll()
294301
} else {

frontends/web/src/routes/account/send/feetargets.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ interface FeeTargetsProps {
3838
disabled: boolean;
3939
fiatUnit: Fiat;
4040
proposedFee?: AmountWithConversions;
41-
feePerByte: number;
41+
feePerByte: string;
4242
showCalculatingFeeLabel?: boolean;
4343
onFeeTargetChange: (code: Code) => void;
44-
onFeePerByte: (feePerByte: number) => void;
44+
onFeePerByte: (feePerByte: string) => void;
4545
error?: string;
4646
}
4747

@@ -104,7 +104,7 @@ class FeeTargets extends Component<Props, State> {
104104

105105
private handleFeePerByte = (event: Event) => {
106106
const target = event.target as HTMLInputElement;
107-
this.props.onFeePerByte(Number(target.value));
107+
this.props.onFeePerByte(target.value);
108108
}
109109

110110
private setFeeTarget = (feeTarget: Code) => {

frontends/web/src/routes/account/send/send.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ interface State {
8383
fiatUnit: Fiat;
8484
sendAll: boolean;
8585
feeTarget?: FeeCode;
86-
feePerByte: number;
86+
feePerByte: string;
8787
isConfirming: boolean;
8888
isSent: boolean;
8989
isAborted: boolean;
@@ -134,7 +134,7 @@ class Send extends Component<Props, State> {
134134
activeScanQR: false,
135135
videoLoading: false,
136136
note: '',
137-
feePerByte: 1,
137+
feePerByte: '',
138138
};
139139

140140
private coinSupportsCoinControl = () => {
@@ -234,7 +234,7 @@ class Send extends Component<Props, State> {
234234
amount: undefined,
235235
data: undefined,
236236
note: '',
237-
feePerByte: 1,
237+
feePerByte: '',
238238
});
239239
if (this.utxos) {
240240
(this.utxos as any).getWrappedInstance().clear();
@@ -268,7 +268,7 @@ class Send extends Component<Props, State> {
268268

269269
private sendDisabled = () => {
270270
const txInput = this.txInput();
271-
return !txInput.address || this.state.feeTarget === undefined || (txInput.sendAll === 'no' && !txInput.amount);
271+
return !txInput.address || this.state.feeTarget === undefined || (txInput.sendAll === 'no' && !txInput.amount) || (this.state.feeTarget === 'custom' && !this.state.feePerByte);
272272
}
273273

274274
private validateAndDisplayFee = (updateFiat: boolean = true) => {

frontends/web/test/routes/account/send/feetargets.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe('routes/account/send/feetargets', () => {
7575
USD: '0.02',
7676
},
7777
}}
78-
feePerByte={1}
78+
feePerByte=""
7979
onFeePerByte={jest.fn()}
8080
onFeeTargetChange={jest.fn()} />,
8181
);
@@ -94,7 +94,7 @@ describe('routes/account/send/feetargets', () => {
9494
coinCode="eth"
9595
disabled={false}
9696
fiatUnit="EUR"
97-
feePerByte={1}
97+
feePerByte=""
9898
onFeePerByte={jest.fn()}
9999
onFeeTargetChange={jest.fn()} />,
100100
);
@@ -121,7 +121,7 @@ describe('routes/account/send/feetargets', () => {
121121
coinCode="btc"
122122
disabled={false}
123123
fiatUnit="USD"
124-
feePerByte={1}
124+
feePerByte=""
125125
onFeePerByte={jest.fn()}
126126
onFeeTargetChange={onFeeTargetChangeCB} />,
127127
);

0 commit comments

Comments
 (0)