Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 90 additions & 1 deletion packages/bull_sdk/lib/src/rust/frb_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class BullSdk extends BaseEntrypoint<BullSdkApi, BullSdkApiImpl, BullSdkWire> {
String get codegenVersion => '2.12.0';

@override
int get rustContentHash => 2124457774;
int get rustContentHash => -1340504436;

static const kDefaultExternalLibraryLoaderConfig =
ExternalLibraryLoaderConfig(
Expand Down Expand Up @@ -369,6 +369,12 @@ abstract class BullSdkApi extends BaseApi {

Future<Address> lwkApiWalletWalletAddressLastUnused({required Wallet that});

Future<AddressWithBlindingSecret>
lwkApiWalletWalletAddressWithBlindingSecret({
required Wallet that,
required int index,
});

Future<List<Balance>> lwkApiWalletWalletBalances({required Wallet that});

Future<String> lwkApiWalletWalletBlindingKey({required Wallet that});
Expand Down Expand Up @@ -3066,6 +3072,44 @@ class BullSdkApiImpl extends BullSdkApiImplPlatform implements BullSdkApi {
argNames: ["that"],
);

@override
Future<AddressWithBlindingSecret>
lwkApiWalletWalletAddressWithBlindingSecret({
required Wallet that,
required int index,
}) {
return handler.executeNormal(
NormalTask(
callFfi: (port_) {
var arg0 =
cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerWallet(
that,
);
var arg1 = cst_encode_u_32(index);
return wire
.wire__lwk__api__wallet__Wallet_address_with_blinding_secret(
port_,
arg0,
arg1,
);
},
codec: DcoCodec(
decodeSuccessData: dco_decode_address_with_blinding_secret,
decodeErrorData: dco_decode_lwk_error,
),
constMeta: kLwkApiWalletWalletAddressWithBlindingSecretConstMeta,
argValues: [that, index],
apiImpl: this,
),
);
}

TaskConstMeta get kLwkApiWalletWalletAddressWithBlindingSecretConstMeta =>
const TaskConstMeta(
debugName: "Wallet_address_with_blinding_secret",
argNames: ["that", "index"],
);

@override
Future<List<Balance>> lwkApiWalletWalletBalances({required Wallet that}) {
return handler.executeNormal(
Expand Down Expand Up @@ -7796,6 +7840,20 @@ class BullSdkApiImpl extends BullSdkApiImplPlatform implements BullSdkApi {
);
}

@protected
AddressWithBlindingSecret dco_decode_address_with_blinding_secret(
dynamic raw,
) {
// Codec=Dco (DartCObject based), see doc to use other codecs
final arr = raw as List<dynamic>;
if (arr.length != 2)
throw Exception('unexpected arr length: expect 2 but see ${arr.length}');
return AddressWithBlindingSecret(
address: dco_decode_address(arr[0]),
blindingSecret: dco_decode_String(arr[1]),
);
}

@protected
ArkBalance dco_decode_ark_balance(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
Expand Down Expand Up @@ -9359,6 +9417,19 @@ class BullSdkApiImpl extends BullSdkApiImplPlatform implements BullSdkApi {
);
}

@protected
AddressWithBlindingSecret sse_decode_address_with_blinding_secret(
SseDeserializer deserializer,
) {
// Codec=Sse (Serialization based), see doc to use other codecs
var var_address = sse_decode_address(deserializer);
var var_blindingSecret = sse_decode_String(deserializer);
return AddressWithBlindingSecret(
address: var_address,
blindingSecret: var_blindingSecret,
);
}

@protected
ArkBalance sse_decode_ark_balance(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
Expand Down Expand Up @@ -11561,6 +11632,16 @@ class BullSdkApiImpl extends BullSdkApiImplPlatform implements BullSdkApi {
sse_encode_opt_String(self.blindingKey, serializer);
}

@protected
void sse_encode_address_with_blinding_secret(
AddressWithBlindingSecret self,
SseSerializer serializer,
) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_address(self.address, serializer);
sse_encode_String(self.blindingSecret, serializer);
}

@protected
void sse_encode_ark_balance(ArkBalance self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
Expand Down Expand Up @@ -13300,6 +13381,14 @@ class WalletImpl extends RustOpaque implements Wallet {
Future<Address> addressLastUnused() =>
BullSdk.instance.api.lwkApiWalletWalletAddressLastUnused(that: this);

/// Get an address and the secret blinding key derived specifically for it.
Future<AddressWithBlindingSecret> addressWithBlindingSecret({
required int index,
}) => BullSdk.instance.api.lwkApiWalletWalletAddressWithBlindingSecret(
that: this,
index: index,
);

/// Get balances for a wallet.
Future<List<Balance>> balances() =>
BullSdk.instance.api.lwkApiWalletWalletBalances(that: this);
Expand Down
55 changes: 55 additions & 0 deletions packages/bull_sdk/lib/src/rust/frb_generated.io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ abstract class BullSdkApiImplPlatform extends BaseApiImpl<BullSdkWire> {
@protected
Address dco_decode_address(dynamic raw);

@protected
AddressWithBlindingSecret dco_decode_address_with_blinding_secret(
dynamic raw,
);

@protected
ArkBalance dco_decode_ark_balance(dynamic raw);

Expand Down Expand Up @@ -784,6 +789,11 @@ abstract class BullSdkApiImplPlatform extends BaseApiImpl<BullSdkWire> {
@protected
Address sse_decode_address(SseDeserializer deserializer);

@protected
AddressWithBlindingSecret sse_decode_address_with_blinding_secret(
SseDeserializer deserializer,
);

@protected
ArkBalance sse_decode_ark_balance(SseDeserializer deserializer);

Expand Down Expand Up @@ -1844,6 +1854,15 @@ abstract class BullSdkApiImplPlatform extends BaseApiImpl<BullSdkWire> {
wireObj.blinding_key = cst_encode_opt_String(apiObj.blindingKey);
}

@protected
void cst_api_fill_to_wire_address_with_blinding_secret(
AddressWithBlindingSecret apiObj,
wire_cst_address_with_blinding_secret wireObj,
) {
cst_api_fill_to_wire_address(apiObj.address, wireObj.address);
wireObj.blinding_secret = cst_encode_String(apiObj.blindingSecret);
}

@protected
void cst_api_fill_to_wire_ark_balance(
ArkBalance apiObj,
Expand Down Expand Up @@ -3030,6 +3049,12 @@ abstract class BullSdkApiImplPlatform extends BaseApiImpl<BullSdkWire> {
@protected
void sse_encode_address(Address self, SseSerializer serializer);

@protected
void sse_encode_address_with_blinding_secret(
AddressWithBlindingSecret self,
SseSerializer serializer,
);

@protected
void sse_encode_ark_balance(ArkBalance self, SseSerializer serializer);

Expand Down Expand Up @@ -4801,6 +4826,30 @@ class BullSdkWire implements BaseWire {
_wire__lwk__api__wallet__Wallet_address_last_unusedPtr
.asFunction<void Function(int, int)>();

void wire__lwk__api__wallet__Wallet_address_with_blinding_secret(
int port_,
int that,
int index,
) {
return _wire__lwk__api__wallet__Wallet_address_with_blinding_secret(
port_,
that,
index,
);
}

late final _wire__lwk__api__wallet__Wallet_address_with_blinding_secretPtr =
_lookup<
ffi.NativeFunction<
ffi.Void Function(ffi.Int64, ffi.UintPtr, ffi.Uint32)
>
>(
'frbgen_bull_sdk_wire__lwk__api__wallet__Wallet_address_with_blinding_secret',
);
late final _wire__lwk__api__wallet__Wallet_address_with_blinding_secret =
_wire__lwk__api__wallet__Wallet_address_with_blinding_secretPtr
.asFunction<void Function(int, int, int)>();

void wire__lwk__api__wallet__Wallet_balances(int port_, int that) {
return _wire__lwk__api__wallet__Wallet_balances(port_, that);
}
Expand Down Expand Up @@ -9902,6 +9951,12 @@ final class wire_cst_list_tx_output extends ffi.Struct {
external int len;
}

final class wire_cst_address_with_blinding_secret extends ffi.Struct {
external wire_cst_address address;

external ffi.Pointer<wire_cst_list_prim_u_8_strict> blinding_secret;
}

final class wire_cst_ark_boarding extends ffi.Struct {
@ffi.Int64()
external int unconfirmed;
Expand Down
22 changes: 22 additions & 0 deletions packages/bull_sdk/lib/src/rust/third_party/lwk/api/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,28 @@ class Address {
blindingKey == other.blindingKey;
}

/// A wallet address paired with the secret blinding key derived for that address.
class AddressWithBlindingSecret {
final Address address;
final String blindingSecret;

const AddressWithBlindingSecret({
required this.address,
required this.blindingSecret,
});

@override
int get hashCode => address.hashCode ^ blindingSecret.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is AddressWithBlindingSecret &&
runtimeType == other.runtimeType &&
address == other.address &&
blindingSecret == other.blindingSecret;
}

/// Balance represents a balance of a specific asset
class Balance {
final String assetId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ abstract class Wallet implements RustOpaqueInterface {
/// Get the last unused address from the wallet
Future<Address> addressLastUnused();

/// Get an address and the secret blinding key derived specifically for it.
Future<AddressWithBlindingSecret> addressWithBlindingSecret({
required int index,
});

/// Get balances for a wallet.
Future<List<Balance>> balances();

Expand Down
5 changes: 4 additions & 1 deletion packages/bull_sdk/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ bitbox = { git = "https://github.com/SatoshiPortal/bitbox-dart", rev = "c110af75
bbqr = { git = "https://github.com/SatoshiPortal/bbqr-rust.git", rev = "2296a713beb58a175eb620a087f7da6826dc6f70", default-features = false }
dart_bbqr = { git = "https://github.com/SatoshiPortal/bbqr-dart", rev = "50b2397a708aa8083c22ae80a49e4dd0d503632e", features = ["bull_sdk"] }
boltz = { git = "https://github.com/SatoshiPortal/boltz-dart", tag = "v0.5.1", features = ["bull_sdk"] }
lwk = { git = "https://github.com/SatoshiPortal/lwk-dart", tag = "v0.5.0", features = ["bull_sdk"] }
lwk = { git = "https://github.com/SatoshiPortal/lwk-dart", rev = "355dd786a634ae7dae8e55e82e9ba5f90a6ce6f5", features = ["bull_sdk"] }

[dev-dependencies]
secp256k1-zkp = "0.11.0"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(frb_expand)'] }
Loading