Merge pull request #4144 from BlueWallet/bump-ldk

WIP: maturing ETA for ldk onchain balance
This commit is contained in:
GLaDOS 2021-11-02 14:45:28 +00:00 committed by GitHub
commit b9ca9ce25d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 3 deletions

View File

@ -110,6 +110,10 @@ export class LightningLdkWallet extends LightningCustodianWallet {
return RnLdk.getMaturingBalance();
}
async getMaturingHeight(): Promise<number> {
return RnLdk.getMaturingHeight();
}
/**
* Probes getNodeId() call. if its available - LDK has started
*

4
package-lock.json generated
View File

@ -20918,8 +20918,8 @@
}
},
"rn-ldk": {
"version": "git+https://github.com/BlueWallet/rn-ldk.git#0a68c7b7d0c95bfedda0a0ae2028a56dc6af3584",
"from": "git+https://github.com/BlueWallet/rn-ldk.git#v0.5.2"
"version": "git+https://github.com/BlueWallet/rn-ldk.git#v0.6.0",
"from": "git+https://github.com/BlueWallet/rn-ldk.git#v0.6.0"
},
"rn-nodeify": {
"version": "10.3.0",

View File

@ -189,7 +189,7 @@
"react-test-render": "1.1.2",
"readable-stream": "3.6.0",
"realm": "10.9.1",
"rn-ldk": "git+https://github.com/BlueWallet/rn-ldk.git#v0.5.2",
"rn-ldk": "git+https://github.com/BlueWallet/rn-ldk.git#v0.6.0",
"rn-nodeify": "10.3.0",
"scryptsy": "2.1.0",
"secure-random": "1.1.2",

View File

@ -41,6 +41,7 @@ const LdkInfo = () => {
const [pendingChannels, setPendingChannels] = useState<any[]>([]);
const [wBalance, setWalletBalance] = useState<{ confirmedBalance?: number }>({});
const [maturingBalance, setMaturingBalance] = useState(0);
const [maturingEta, setMaturingEta] = useState('');
const centerContent = channels.length === 0 && pendingChannels.length === 0 && inactiveChannels.length === 0;
const allChannelsAmount = useRef(0);
// Modals
@ -118,6 +119,16 @@ const LdkInfo = () => {
setWalletBalance(walletBalance);
setMaturingBalance(await wallet.getMaturingBalance());
const maturingHeight = await wallet.getMaturingHeight();
if (maturingHeight > 0) {
const result = await fetch('https://blockstream.info/api/blocks/tip/height');
const tip = await result.text();
const hrs = Math.ceil((maturingHeight - +tip) / 6); // convert blocks to hours
setMaturingEta(`${hrs} hours`);
} else {
setMaturingEta('');
}
} catch (e) {
console.log(e);
} finally {
@ -417,6 +428,7 @@ const LdkInfo = () => {
</>
) : null}
{maturingBalance ? <Text style={[stylesHook.detailsText]}>Balance awaiting confirmations: {maturingBalance} sat</Text> : null}
{maturingEta ? <Text style={[stylesHook.detailsText]}>ETA: {maturingEta}</Text> : null}
<Button text={loc.lnd.new_channel} onPress={navigateToOpenPrivateChannel} disabled={isLoading} />
<BlueSpacing20 />
</View>