Skip to content

Commit

Permalink
Changes the return
Browse files Browse the repository at this point in the history
  • Loading branch information
ademar111190 committed Aug 15, 2023
1 parent 43ffa20 commit 09d722a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 25 deletions.
3 changes: 1 addition & 2 deletions libs/sdk-bindings/src/breez_sdk.udl
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,7 @@ dictionary PrepareWithdrawRequest {
};

dictionary PrepareWithdrawResponse {
string raw_tx_hex;
u32 sat_per_vbyte;
u32 weight;
u64 fee_sat;
};

Expand Down
7 changes: 1 addition & 6 deletions libs/sdk-core/src/bridge_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1235,12 +1235,7 @@ impl support::IntoDart for PaymentType {
impl support::IntoDartExceptPrimitive for PaymentType {}
impl support::IntoDart for PrepareWithdrawResponse {
fn into_dart(self) -> support::DartAbi {
vec![
self.raw_tx_hex.into_dart(),
self.sat_per_vbyte.into_dart(),
self.fee_sat.into_dart(),
]
.into_dart()
vec![self.weight.into_dart(), self.fee_sat.into_dart()].into_dart()
}
}
impl support::IntoDartExceptPrimitive for PrepareWithdrawResponse {}
Expand Down
4 changes: 1 addition & 3 deletions libs/sdk-core/src/greenlight/node_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use gl_client::signer::Signer;
use gl_client::tls::TlsConfig;
use gl_client::{node, pb, utils};
use lightning::util::message_signing::verify;
use lightning::util::ser::Writeable;
use lightning_invoice::{RawInvoice, SignedRawInvoice};
use serde::{Deserialize, Serialize};
use strum_macros::{Display, EnumString};
Expand Down Expand Up @@ -500,8 +499,7 @@ impl NodeAPI for Greenlight {
debug!("tx_prepare response: {:?}", response);
debug!("raw_tx_hex: {:?}", String::from_utf8(response.unsigned_tx)?);
return Ok(PrepareWithdrawResponse {
raw_tx_hex: String::new(), //String::from_utf8(response.unsigned_tx)?,
sat_per_vbyte: prepare_withdraw_request.fee_rate_sats_per_vbyte,
weight: 10,
fee_sat: 50,
});
}
Expand Down
6 changes: 2 additions & 4 deletions libs/sdk-core/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,12 +1018,10 @@ pub struct PrepareWithdrawRequest {
}

/// We need to prepare a withdraw transaction to know what a fee it will be charged in satoshis
/// this model holds the response data, which consists of the raw transaction hex, the fee rate in
/// vbyte and the consolidate fee in satoshis.
/// this model holds the response data, which consists of the weight and the absolute fee in sats
#[derive(PartialEq, Eq, Debug, Clone, Deserialize, Serialize)]
pub struct PrepareWithdrawResponse {
pub raw_tx_hex: String,
pub sat_per_vbyte: u32,
pub weight: u32,
pub fee_sat: u64,
}

Expand Down
16 changes: 6 additions & 10 deletions libs/sdk-flutter/lib/bridge_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -972,16 +972,13 @@ class PrepareWithdrawRequest {
}

/// We need to prepare a withdraw transaction to know what a fee it will be charged in satoshis
/// this model holds the response data, which consists of the raw transaction hex, the fee rate in
/// vbyte and the consolidate fee in satoshis.
/// this model holds the response data, which consists of the weight and the absolute fee in sats
class PrepareWithdrawResponse {
final String rawTxHex;
final int satPerVbyte;
final int weight;
final int feeSat;

const PrepareWithdrawResponse({
required this.rawTxHex,
required this.satPerVbyte,
required this.weight,
required this.feeSat,
});
}
Expand Down Expand Up @@ -2724,11 +2721,10 @@ class BreezSdkCoreImpl implements BreezSdkCore {

PrepareWithdrawResponse _wire2api_prepare_withdraw_response(dynamic raw) {
final arr = raw as List<dynamic>;
if (arr.length != 3) throw Exception('unexpected arr length: expect 3 but see ${arr.length}');
if (arr.length != 2) throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
return PrepareWithdrawResponse(
rawTxHex: _wire2api_String(arr[0]),
satPerVbyte: _wire2api_u32(arr[1]),
feeSat: _wire2api_u64(arr[2]),
weight: _wire2api_u32(arr[0]),
feeSat: _wire2api_u64(arr[1]),
);
}

Expand Down

0 comments on commit 09d722a

Please sign in to comment.