Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Undelegation #63

Merged
merged 1 commit into from
Nov 27, 2022
Merged
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
4 changes: 1 addition & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1708,9 +1708,7 @@ <h4 id="signed-raw">Signed Raw Transaction</h4>
}

// The primary Standard-to-Cold output
// Until we can get blockbook to tell us which address are involved in cold staking
// We will only use the first key
cTx.addcoldstakingoutput(await masterKey.getAddress(getDerivationPath(masterKey.isHardwareWallet)), coldAddr, nValue / COIN);
cTx.addcoldstakingoutput(await getNewAddress(), coldAddr, nValue / COIN);

// Debug-only verbose response
if (debug) domHumanReadable.innerHTML = "Balance: " + (nBalance / COIN) + "<br>Fee: " + (nFee / COIN) + "<br>To: " + coldAddr + "<br>Sent: " + (nValue / COIN) + (nChange > 0 ? "<br>Change Address: " + changeAddress + "<br>Change: " + (nChange / COIN) : "");
Expand Down
38 changes: 13 additions & 25 deletions scripts/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,31 +248,19 @@ var getUTXOsHeavy = async function() {
for (const cOut of cTx.vout) {
if (cOut.spent) continue; // We don't care about spent outputs
const paths = cOut.addresses.map(strAddr => mapPaths.get(strAddr)).filter(v => v);
// If an absence of any address, or a Cold Staking address is detected, we mark this as a delegated UTXO
if (cOut.addresses.length === 0 || cOut.addresses.some(strAddr => strAddr.startsWith(cChainParams.current.STAKING_PREFIX))) {
arrDelegatedUTXOs.push({
'id': cTx.txid,
'vout': cOut.n,
'sats': parseInt(cOut.value),
'script': cOut.hex,
// Until we can get blockbook to tell us which address are involved in cold staking
// We will only use the first key
'path': getDerivationPath(masterKey.isHardwareWallet),
});
}
// Otherwise, an address matches one of ours
else if (paths.length > 0) {
// Blockbook still returns 119' as the coinType, even in testnet
let path = paths[0].split("/");
path[2] = (masterKey.isHardwareWallet ? cChainParams.current.BIP44_TYPE_LEDGER : cChainParams.current.BIP44_TYPE) + "'";
cachedUTXOs.push({
'id': cTx.txid,
'vout': cOut.n,
'sats': parseInt(cOut.value),
'script': cOut.hex,
'path': path.join("/"),
});
}
// No addresses match ours
if (!paths.length) continue;
const arrToPush = cOut.addresses.some(strAddr => strAddr.startsWith(cChainParams.current.STAKING_PREFIX)) ? arrDelegatedUTXOs : cachedUTXOs;
// Blockbook still returns 119' as the coinType, even in testnet
let path = paths[0].split("/");
path[2] = (masterKey.isHardwareWallet ? cChainParams.current.BIP44_TYPE_LEDGER : cChainParams.current.BIP44_TYPE) + "'";
arrToPush.push({
'id': cTx.txid,
'vout': cOut.n,
'sats': parseInt(cOut.value),
'script': cOut.hex,
'path': path.join("/"),
});
}
}
// Update UI
Expand Down