REF
This commit is contained in:
parent
e6dc7f99f5
commit
265abdc639
@ -364,8 +364,14 @@ export default class Ldk {
|
||||
async reconnectPeers() {
|
||||
const peers2reconnect = {};
|
||||
|
||||
const listPeers = await this.listPeers();
|
||||
const listChannels = await this.listChannels();
|
||||
let listPeers, listChannels;
|
||||
|
||||
try {
|
||||
listPeers = await this.listPeers();
|
||||
listChannels = await this.listChannels();
|
||||
} catch (_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// do we have any channels that need reconnection with peers..?
|
||||
for (const channel of listChannels) {
|
||||
|
||||
@ -15,6 +15,7 @@ const fetcher = async (arg1) => {
|
||||
ldk.setSecret(util.getHotSeed());
|
||||
|
||||
if (+new Date() - lastBlockchainSync > 5 * 60 * 1000) { // 5 min
|
||||
console.log('syncing blockchain...')
|
||||
lastBlockchainSync = +new Date();
|
||||
await ldk.setRefundAddress(ldk.unwrapFirstExternalAddressFromMnemonics());
|
||||
maturingBalance = await ldk.getMaturingBalance();
|
||||
@ -57,9 +58,13 @@ export default function Gsom(props: DefaultScreenProps) {
|
||||
console.log();
|
||||
|
||||
;(async () => {
|
||||
await ldk.setRefundAddress(ldk.unwrapFirstExternalAddressFromMnemonics());
|
||||
await ldk.updateFeerate(); // so any refund claim upon startup would use adequate fee
|
||||
await ldk.start(ldk.getEntropyHex());
|
||||
try {
|
||||
await ldk.setRefundAddress(ldk.unwrapFirstExternalAddressFromMnemonics());
|
||||
await ldk.updateFeerate(); // so any refund claim upon startup would use adequate fee
|
||||
await ldk.start(ldk.getEntropyHex());
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
@ -72,6 +77,16 @@ export default function Gsom(props: DefaultScreenProps) {
|
||||
);
|
||||
};
|
||||
|
||||
const renderChannelsList = () => {
|
||||
const listItems = (listchannels || []).map((cha) =>
|
||||
<li key={cha.channel_id}>{cha?.counterparty_node_id || '?'} {cha?.is_usable ? '[usable]' : ''} {cha?.is_funding_locked ? '' : '[funding not locked]'}</li>
|
||||
|
||||
);
|
||||
return (
|
||||
<ul>{listItems}</ul>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
<div className="container">
|
||||
@ -97,7 +112,7 @@ export default function Gsom(props: DefaultScreenProps) {
|
||||
</div>
|
||||
<div className="col">
|
||||
channels:<br/>
|
||||
todo<br/>
|
||||
{renderChannelsList()}
|
||||
Peers:<br/>
|
||||
{renderPeersList()}
|
||||
<button type="button" className="btn btn-outline-primary">manage channels</button><br/>
|
||||
@ -105,7 +120,6 @@ export default function Gsom(props: DefaultScreenProps) {
|
||||
const uri = prompt('input node uri');
|
||||
if (!uri) return;
|
||||
|
||||
|
||||
const pubkey = uri.split('@')[0];
|
||||
const [host, port] = uri.split('@')[1]?.split(':')
|
||||
if (!pubkey || !host || !port) return;
|
||||
|
||||
@ -44,7 +44,7 @@ class Executor {
|
||||
return helperJsonResponseSuccess("ok")
|
||||
}
|
||||
"ldkversion" -> return helperJsonResponseSuccess((org.ldk.impl.version.get_ldk_java_bindings_version() + ", " + org.ldk.impl.bindings.get_ldk_c_bindings_version() + ", " + org.ldk.impl.bindings.get_ldk_version()))
|
||||
"version" -> return helperJsonResponseSuccess("1.2.1")
|
||||
"version" -> return helperJsonResponseSuccess("1.2.2")
|
||||
"connectpeer" -> {
|
||||
if (arg1 == null || arg2 == null || arg3 == null) return helperJsonResponseFailure("incorrect arguments")
|
||||
var retValue = "";
|
||||
|
||||
@ -89,7 +89,7 @@ fun channel2channelObject(it: ChannelDetails): String {
|
||||
channelObject += "\"is_public\":" + it._is_public + ",";
|
||||
val fundingTxoTxid = it._funding_txo?._txid;
|
||||
if (fundingTxoTxid is ByteArray) {
|
||||
channelObject += "\"funding_txo_txid\":" + "\"" + byteArrayToHex(fundingTxoTxid) + "\",";
|
||||
channelObject += "\"funding_txo_txid\":" + "\"" + byteArrayToHex(fundingTxoTxid.reversedArray()) + "\",";
|
||||
}
|
||||
val fundingTxoIndex = it._funding_txo?._index;
|
||||
if (fundingTxoIndex != null) {
|
||||
|
||||
@ -289,7 +289,7 @@ fun start(
|
||||
override fun register_tx(txid: ByteArray, script_pubkey: ByteArray) {
|
||||
println("ReactNativeLDK: register_tx");
|
||||
val params = WritableMap()
|
||||
params.putString("txid", byteArrayToHex(txid))
|
||||
params.putString("txid", byteArrayToHex(txid.reversedArray()))
|
||||
params.putString("script_pubkey", byteArrayToHex(script_pubkey))
|
||||
storeEvent("$homedir/events_register_tx", params)
|
||||
eventsRegisterTx = eventsRegisterTx.plus(params.toString())
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user