Skip to content

Commit

Permalink
send transactions; get address and tx info
Browse files Browse the repository at this point in the history
  • Loading branch information
tylersavery committed Mar 15, 2024
1 parent 96b0d5e commit dc43d22
Show file tree
Hide file tree
Showing 11 changed files with 6,601 additions and 850 deletions.
5,121 changes: 5,031 additions & 90 deletions example/btc.js

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions example/index.html
Expand Up @@ -48,12 +48,23 @@ <h3>Email/Password</h3>
<button id="buttonEmailPassword">Login</button>


<h2>Transactions</h2>

<button id="buttonSendTx">Send TX</button>


<h3>Address Info</h3>
<input id="inputAddressInfo" value="tb1qh0nx4epkftfz3gmztkg9qmcyez604q36snzg0n" placeholder="BTC Address">
<button id="buttonAddressInfo">Get Info</button>




<script>

const keypairService = new btc.KeypairService(true);
const transactionService = new btc.TransactionService(true);
const accountService = new btc.AccountService(true);

window.onload = () => {

Expand Down Expand Up @@ -95,6 +106,34 @@ <h3>Email/Password</h3>
console.log(data);

}

const buttonSendTx = document.getElementById('buttonSendTx');

buttonSendTx.onclick = async() => {

const senderWif = "cPQ5kbnuj8YmBoCaFmsPsZENVykN1GGmF18mg6sEZsJPX2np6PRa"
const senderAddress = "tb1qh0nx4epkftfz3gmztkg9qmcyez604q36snzg0n"
const recipientAddress = "tb1q4lahda9feljf695q473z4m8m7xhgzv35n6226q"
const amount = 0.000003

const data = await transactionService.createTransaction(senderWif, senderAddress, recipientAddress, amount);

if(data.success) {
console.log("Success")
console.log("Tx Hash: ", data.result.tx.hash)
}else {
console.log("Error")
console.log(data.error)
}
}


const buttonAddressInfo = document.getElementById("buttonAddressInfo");
buttonAddressInfo.onclick = async () => {
const address = document.getElementById('inputAddressInfo').value.trim()
const data = await accountService.addressInfo(address);
console.log(data);
}
}
</script>

Expand Down

0 comments on commit dc43d22

Please sign in to comment.