Skip to content
Open
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
2 changes: 1 addition & 1 deletion cw_monero/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies:
monero:
git:
url: https://github.com/mrcyjanek/monero_c.git
ref: 3bfb3856a838f2bf6b729501837bb0295dedf25d
ref: cd4fe366cc8d3c188c91de279f43b29c0e044b15
path: impls/monero.dart
mutex: ^3.1.0
ledger_flutter_plus: ^1.4.1
Expand Down
2 changes: 1 addition & 1 deletion cw_wownero/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
monero:
git:
url: https://github.com/mrcyjanek/monero_c.git
ref: 3bfb3856a838f2bf6b729501837bb0295dedf25d
ref: cd4fe366cc8d3c188c91de279f43b29c0e044b15
path: impls/monero.dart
mutex: ^3.1.0

Expand Down
9 changes: 7 additions & 2 deletions cw_zano/lib/api/model/transfer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ class Transfer {
? []
: (json['remote_aliases'] as List<dynamic>).cast<String>(),
showSender: json['show_sender'] as bool? ?? false,
subtransfers: (json['subtransfers'] as List<dynamic>? ?? [])
.map((e) => Subtransfer.fromJson(e as Map<String, dynamic>))
subtransfers: (json['subtransfers_by_pid'] as List<dynamic>? ?? [])
.whereType<Map<String, dynamic>>()
.expand(
(group) => (group['subtransfers'] as List<dynamic>? ?? [])
.whereType<Map<String, dynamic>>()
.map(Subtransfer.fromJson),
)
.toList(),
timestamp: json['timestamp'] as int? ?? 0,
transferInternalIndex: json['transfer_internal_index'] == null
Expand Down
60 changes: 60 additions & 0 deletions cw_zano/lib/bip39_seed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import 'dart:typed_data';

import 'package:bip32/bip32.dart' as bip32;
import 'package:bip39/bip39.dart' as bip39;
import 'package:bip39/src/wordlists/english.dart' as bip39_english;

bool isBip39Seed(String mnemonic) => bip39.validateMnemonic(mnemonic);

List<String> get bip39EnglishWords => List<String>.from(bip39_english.WORDLIST);

String generateBip39Mnemonic({int strength = 128}) =>
bip39.generateMnemonic(strength: strength);

String getSecretDerivationFromBip39(String mnemonic, {String passphrase = ''}) {
final seed = bip39.mnemonicToSeed(mnemonic, passphrase: passphrase);

final bip32KeyPair = bip32.BIP32.fromSeed(seed).derivePath("m/44'/128'/0'/0/0");

return _reduceECKey(bip32KeyPair.privateKey!).toHexString();
}

const _ed25519CurveOrder = "1000000000000000000000000000000014DEF9DEA2F79CD65812631A5CF5D3ED";

Uint8List _reduceECKey(Uint8List buffer) {
final curveOrder = BigInt.parse(_ed25519CurveOrder, radix: 16);
final bigNumber = _readBytes(buffer);

var result = bigNumber % curveOrder;

final resultBuffer = Uint8List(32);
for (var i = 0; i < 32; i++) {
resultBuffer[i] = (result & BigInt.from(0xff)).toInt();
result = result >> 8;
}

return resultBuffer;
}

/// Read BigInt from a little-endian Uint8List
/// From https://github.com/dart-lang/sdk/issues/32803#issuecomment-387405784
BigInt _readBytes(Uint8List bytes) {
BigInt read(int start, int end) {
if (end - start <= 4) {
var result = 0;
for (int i = end - 1; i >= start; i--) {
result = result * 256 + bytes[i];
}
return BigInt.from(result);
}
final mid = start + ((end - start) >> 1);
return read(start, mid) + read(mid, end) * (BigInt.one << ((mid - start) * 8));
}

return read(0, bytes.length);
}

extension on Uint8List {
String toHexString() =>
map((b) => b.toRadixString(16).padLeft(2, '0')).join();
}
4 changes: 4 additions & 0 deletions cw_zano/lib/get_height_by_data.txt
Comment thread
OmarHatem28 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NODE=http://37.27.100.59:10500/json_rpc
HEIGHT=$(curl -s -X POST $NODE -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"getinfo"}' | python3 -c "import sys,json; print(json.load(sys.stdin)['result']['height'])")
echo "_Checkpoint($(curl -s -X POST $NODE -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"getblockheaderbyheight","params":{"height":1}}' | python3 -c "import sys,json; print(json.load(sys.stdin)['result']['block_header']['timestamp'])"), 1),"
for i in $(seq 1 $((HEIGHT/10000))); do echo "_Checkpoint($(curl -s -X POST $NODE -H 'Content-Type: application/json' -d "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"getblockheaderbyheight\",\"params\":{\"height\":${i}0000}}" | python3 -c "import sys,json; print(json.load(sys.stdin)['result']['block_header']['timestamp'])"), ${i}0000),"; done
Loading
Loading