Skip to content

Commit

Permalink
Fix message subwallet
Browse files Browse the repository at this point in the history
  • Loading branch information
n9lsjr committed Feb 19, 2024
1 parent aa4b3d4 commit 8123c7a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion controllers/latest/postController.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const postController = {}
postController.sendMessage = async (req, res) => {
try {
const result = await wallet.sendTransactionAdvanced(
[[wallet.getPrimaryAddress(), 1]], // destinations,
[[wallet.getAddresses()[1], 1]], // destinations,
3, // mixin
{ fixedFee: 1000, isFixedFee: true }, // fee
undefined, //paymentID
Expand Down
7 changes: 6 additions & 1 deletion utils/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,15 @@ async function optimizeMessages(nbrOfTxs, fee = 10000, attempt = 0) {
if (attempt > 10) {
return false
}
if (wallet.getAddresses().length === 1) {
const [spendKey, viewKey] = wallet.getPrimaryAddressPrivateKeys()
const subWalletKeys = await wallet.generateDeterministicSubwalletKeys(spendKey, 1)
await wallet.importSubWallet(subWalletKeys.private_key)
}

const [walletHeight, localHeight, networkHeight] = wallet.getSyncStatus()

let inputs = await wallet.subWallets.getSpendableTransactionInputs(wallet.subWallets.getAddresses(), networkHeight)
let inputs = await wallet.subWallets.getSpendableTransactionInputs(wallet.getAddresses()[1], networkHeight)

if (inputs.length > 8) {
return inputs.length
Expand Down

0 comments on commit 8123c7a

Please sign in to comment.