-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: check for unconfirmed transactions
- Loading branch information
1 parent
766b0b6
commit c880960
Showing
6 changed files
with
59 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import request from 'request-promise'; | ||
import os from 'os'; | ||
|
||
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0; | ||
|
||
const rpcUrl = process.env.WALLET_URL; | ||
|
||
const getBaseOptions = () => { | ||
const homeDir = os.homedir(); | ||
const certFile = path.resolve( | ||
`${homeDir}/.chia/mainnet/config/ssl/wallet/private_wallet.crt`, | ||
); | ||
const keyFile = path.resolve( | ||
`${homeDir}/.chia/mainnet/config/ssl/wallet/private_wallet.key`, | ||
); | ||
|
||
const baseOptions = { | ||
method: 'POST', | ||
cert: fs.readFileSync(certFile), | ||
key: fs.readFileSync(keyFile), | ||
}; | ||
|
||
return baseOptions; | ||
}; | ||
|
||
export const hasUnconfirmedTransactions = async () => { | ||
const options = { | ||
url: `${rpcUrl}/get_transactions`, | ||
body: JSON.stringify({}), | ||
}; | ||
|
||
const response = await request(Object.assign({}, getBaseOptions(), options)); | ||
|
||
const data = JSON.parse(response); | ||
|
||
if (data.success) { | ||
return data.transactions.some((transaction) => !transaction.confirmed); | ||
} | ||
|
||
return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters