Skip to content

Commit

Permalink
round satoshis when converting for send
Browse files Browse the repository at this point in the history
  • Loading branch information
tylersavery committed Mar 25, 2024
1 parent dc43d22 commit b25f2c6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion example/btc.js
Expand Up @@ -45640,7 +45640,7 @@
return hashHex;
}
var createTx = async (toAddress, value, env, fromAddress) => {
const valueInSatoshi = value * 1e8;
const valueInSatoshi = Math.round(value * 1e8);
if (!fromAddress || !toAddress || !value || !env) {
return {
code: 0,
Expand Down Expand Up @@ -45927,6 +45927,19 @@
finalTxCount: data.final_n_tx
};
}
async transactions(address, limit = 50, before = null) {
let url = `https://api.blockcypher.com/v1/btc/${this.network === TESTNET3 ? "test3" : "main"}/addrs/${address}/full?limit=${limit}`;
if (before) {
url += `&before=${before}`;
}
const response = await fetch(url);
const data = await response.json();
const transactions = data["txs"];
return {
canLoadMore: data["hasMore"],
transactions
};
}
};

// src/browser.ts
Expand Down
2 changes: 1 addition & 1 deletion src/btc/utils.ts
Expand Up @@ -155,7 +155,7 @@ const getWitnessUtxo = (out: any): any => {
}

export const createTx = async (toAddress: string, value: number, env: "mainnet" | "testnet", fromAddress: string) => {
const valueInSatoshi = value * 100000000;
const valueInSatoshi = Math.round(value * 100000000);
if (!fromAddress || !toAddress || !value || !env) {
return {
code: 0,
Expand Down

0 comments on commit b25f2c6

Please sign in to comment.