Skip to content

Instantly share code, notes, and snippets.

@pinheadmz
Created November 7, 2019 18:47
Show Gist options
  • Save pinheadmz/ef9c46af6b25d8644152e57f3d192969 to your computer and use it in GitHub Desktop.
Save pinheadmz/ef9c46af6b25d8644152e57f3d192969 to your computer and use it in GitHub Desktop.
diff --git a/lib/node/http.js b/lib/node/http.js
index bb48d3a9..ae989fc8 100644
--- a/lib/node/http.js
+++ b/lib/node/http.js
@@ -305,6 +305,20 @@ class HTTP extends Server {
       for (const hash of hashes)
         result.push(util.revHex(hash));

+      if (hashes.length > 0) {
+        const hash = hashes[0];
+        const tx = this.mempool.getTX(hash);
+        const view = await this.mempool.getCoinView(tx);
+        const fee = tx.getFee(view);
+        const valueIn = tx.getInputValue(view);
+
+        console.log(`hash: ${hash.toString('hex')}`);
+        console.log(`tx: `, tx.toJSON());
+        console.log(`view: 1`, view.map);
+        console.log(`fee: ${fee}`);
+        console.log(`valueIn: ${valueIn}`);
+      }
+
       res.json(200, result);
     });
hash: 5eaaaf42e27d5e3811030a45d8dd6df39a48c33d092f24532e29867479495a41
tx:  {
  hash: '415a49797486292e53242f093dc3489af36dddd8450a0311385e7de242afaa5e',
  witnessHash: '415a49797486292e53242f093dc3489af36dddd8450a0311385e7de242afaa5e',
  fee: undefined,
  rate: undefined,
  mtime: 1573152385,
  height: undefined,
  block: undefined,
  time: undefined,
  date: undefined,
  index: undefined,
  version: 1,
  inputs: [
    {
      prevout: [Object],
      script: '4830450221009fd7a9546e5c238f92fc9579f45c70de6135fbcdb0870e84d91215e483ffbf3802200d8524311ae8898174f0c591d5bbffe80658f849608c3b58e6586d4b8e8098e80121022265de018110c2e566ea14dea7c09c2b5436a1e53107813bc7f539fed83c089b',
      witness: '00',
      sequence: 4294967295,
      address: 'moP1epnt6fVb9Q92xNHxFM9CtThf63s7g7',
      coin: undefined
    }
  ],
  outputs: [
    {
      value: 10000000,
      script: '76a9148232ec7b844c27fb269ef1006521939ba45f416788ac',
      address: 'msPP9Egx6JAgKw1SsZoCsNwQN9K9sYZ2Ze'
    },
    {
      value: 4989995460,
      script: '76a914f63a7f046ded1091ab61824dda4c7faaeb77098488ac',
      address: 'n3xtbdRhLaGwb3bU8JBkZ1wNbvrdpDpti3'
    }
  ],
  locktime: 0,
  hex: '0100000001adaa8ea3085ce3dfde19a134516b869cda75fd63a803b754939f2eb26d11c197000000006b4830450221009fd7a9546e5c238f92fc9579f45c70de6135fbcdb0870e84d91215e483ffbf3802200d8524311ae8898174f0c591d5bbffe80658f849608c3b58e6586d4b8e8098e80121022265de018110c2e566ea14dea7c09c2b5436a1e53107813bc7f539fed83c089bffffffff0280969800000000001976a9148232ec7b844c27fb269ef1006521939ba45f416788acc4496d29010000001976a914f63a7f046ded1091ab61824dda4c7faaeb77098488ac00000000'
}
view: 1 Map {
  'adaa8ea3085ce3dfde19a134516b869cda75fd63a803b754939f2eb26d11c197' => Coins { outputs: Map { 0 => [CoinEntry] } }
}
fee: 4540
valueIn: 5000000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment