Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
User input field is not working at all. Is the format fucked up? Any help is appreciated.
Post Body

The user input functions are not working properly. Trying to figure out why. Please help:

  <html lang="en">
  <head>
    <title>Transaction Bundle</title>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <script 
      type="text/javascript" 
      src="https://unpkg.com/[email protected]/bsv.min.js">
    </script>

  </head>
  <body>

  <div id="block">
    <h1 id="head">Raw transaction:</h1> 
    <p id="text"></p>
  </div>

  <div>
    <label for="inputText">Enter Text:</label>
    <input type="text" id="inputText" />
    <button onclick="generateTransaction()">Generate Transaction</button>
  </div>
  <div>
    <label for="userVout">Enter Vout:</label>
    <input type="text" id="userVout" />
  </div>

  <script> 

  var userPrivateKey = 'L1dJbaNK9agysJ1E8YNWgf....';
  var userAddress = '1EmP88KocDDR1tgFVGPW3VHf2ZFYPuNq47';

  async function generateTransaction() {
    var userVout = document.getElementById("userVout").value;

    const utxo = new bsv.Transaction.UnspentOutput({
      "address": userAddress,
      "txid": "14ad3bae80f92c64035eb1679a96c82a5d2bf25bc7064e8540df28561fd6f2a0",
      "vout": userVout,
      "satoshis": 177656,
      "scriptPubKey": "76a91496fe679d81a9e419216f1426d861cd0de0376ca288ac",
    });

    const inputText = document.getElementById("inputText").value;
    const opReturnData = ['19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut', inputText, 'text/plain'];
    const opReturnScript = bsv.Script.buildSafeDataOut(opReturnData);
    const transaction = new bsv.Transaction()
      .from(utxo)
      .to('16EFDTghU8dJDNmtE72XxWJ2SqQnnvzwLu', 1000)
      .addOutput(
        new bsv.Transaction.Output({
          script: opReturnScript,
          satoshis: 0,
        })
      )
      .addOutput(
        new bsv.Transaction.Output({
          script: bsv.Script.buildPublicKeyHashOut('1JxhdrQJ2rB9E79kRHBpzrm97czw4NFAct'),
          satoshis: 1000,
        })
      )
      .addOutput(
        new bsv.Transaction.Output({
          script: bsv.Script.buildPublicKeyHashOut('1MZ169SJWN8Ea9HM36BggQUDwCXWLxTm3C'),
          satoshis: 1000,
        })
      )
      .change(userAddress)
      .sign(userPrivateKey);

    const response = await fetch('https://api.whatsonchain.com/v1/bsv/main/tx/raw', {
      method: 'POST',
      body: JSON.stringify({ txhex: transaction.toString() })
    });

    const responseData = await response.json();
    console.log(responseData);

    var p = document.querySelector("#text");
    p.innerHTML = transaction.toString();
  }
  </script>
  </body>
  </html>

Author
User Suspended
Account Strength
0%
Suspended 4 months ago
Account Age
1 year
Verified Email
Yes
Verified Flair
No
Total Karma
8
Link Karma
5,901
Comment Karma
1,059
Profile updated: 1 week ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
1 year ago