LtbLightning / bdk-flutter

Bitcoin Development Kit - Flutter Package
MIT License
60 stars 27 forks source link

Handling `mempool min fee not met` error #135

Open saiy2k opened 2 weeks ago

saiy2k commented 2 weeks ago

bdk version: 0.31.2-dev.1

With the following code:

try {
  [...]
  await builder.feeRate(0).addRecipient(script, 900).finish(bdkWallet);
} on FeeTooLowException catch (e) {
  print('FeeTooLowException');
  print(e);
} on FeeRateTooLowException catch (e) {
  print('FeeRateTooLowException');
  print(e);
} on RpcException catch (e) {
  print('RpcException');
  print(e);
} on Exception catch (e) {
  print('Exception');
  print(e);
}

No typed Exception is being thrown.

There are typed Exceptions like FeeTooLowException, FeeRateTooLowException (or) since it looks like an RPC error, RpcException could be thrown.

The log goes as follows: BdkError.electrum(field0: Electrum server error: "sendrawtransaction RPC error: {\"code\":-26,\"message\":\"mempool min fee not met, 0 < 13169\"}")

Basically I am trying to get the JSON object {\"code\":-26,\"message\":\"mempool min fee not met, 0 < 13169\"}") embedded inside the error string.

To simulate the issue: https://github.com/saiy2k/Bdk-flutter-Exception-handler

Run the app and press the + floating action button.