-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[RPC] Transaction details in getblock #2506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This could be controlled by yet another rpc parameter or |
@UdjinM6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incomplete and doesn't match the original PR in couple of places unfortunately. Also, this should be based on top of develop
because we do NOT merge into master
neither directly nor via PRs. And finally, while this is nice to have and it is not that invasive, I'm still leaning towards postponing these changes till future backports and not including it in 0.13. @codablock
503a3c8
to
afc39b6
Compare
afc39b6
to
a9ef165
Compare
answered in conversation (
fixed (checkout develop + cherry pick + push --force)
if don’t make it, users will have to patch source and build software to get detailed information about transactions. because after block 264000 in testnet, the parsing of raw blocks with https://github.com/bitcoinjs/bitcoinjs-lib stopped working @codablock @UdjinM6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if don’t make it, users will have to patch source and build software to get detailed information about transactions. because after block 264000 in testnet, the parsing of raw blocks with https://github.com/bitcoinjs/bitcoinjs-lib stopped working
That's interesting. Mind clarifying the problem (error log or anything)? @nmarley , pls note the issue.
Also, see inline comments for requested code changes.
a9ef165
to
36ceb53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@UdjinM6 #2506 (comment) #2506 (comment) - fixed
That's interesting. Mind clarifying the problem (error log or anything)?
That's how I get transactions from the block:
import type { Block, Transaction } from "bitcoinjs-lib";
const bitcoin = require("bitcoinjs-lib");
// here logic of fetching hexFromRpc from rpc...
const parsedBlock: Block = bitcoin.Block.fromHex(hexFromRpc);
const txList: Array<PostProcessedTransactionType> = tx: parsedBlock.transactions.map((tx: Transaction): PostProcessedTransactionType => {
// there is some sort of processing logic
})
this code was valid before block 264000
(dash-testnet)
now it raises an error:
RangeError [ERR_INDEX_OUT_OF_RANGE]: Index out of range\n at checkOffset (buffer.js:1015:11)\n
at Buffer.readUInt32LE (buffer.js:1079:5)\n
at readUInt32 (/home/blockchains-parser/node_modules/bitcoinjs-lib/src/transaction.js:57:20)\n
at Function.Transaction.fromBuffer (/home/blockchains-parser/node_modules/bitcoinjs-lib/src/transaction.js:110:17)\n
at readTransaction (/home/blockchains-parser/node_modules/bitcoinjs-lib/src/block.js:57:26)\n
at Function.Block.fromBuffer (/home/blockchains-parser/node_modules/bitcoinjs-lib/src/block.js:66:14)\n
at Function.Block.fromHex (/home/blockchains-parser/node_modules/bitcoinjs-lib/src/block.js:82:16)
because of this, I will have to patch the code and build the blockchain node from release to release until this code is accepted
PS (off topic)
By the way, it would be nice to add some information to the wiki, who uses rpc and is currently parsing raw blocks using javascript (or making your own fork of bitcoinjs-lib
for dash):
snippet of getting block hash:
import type { Block } from "bitcoinjs-lib";
const multiHashing = require("multi-hashing-bbscoin");
const getBlockHash = (block: Block, typeChain: ?string): string => {
if (["dash", "dash-testnet"].indexOf(typeChain) > -1) {
return multiHashing
.x11(block.toBuffer(true))
.reverse()
.toString("hex");
}
return block.getId();
};
So, it seems like you are fixing the wrong problem :) You should just add DIP2 (https://github.com/dashpay/dips/blob/master/dip-0002.md) support in your bitcoinjs-lib fork, smth like that UdjinM6/bitcoinjs-lib@69807fd |
@UdjinM6 The problem is the impossibility of extracting transaction details from the block.
The first method is the most correct, since it relies on the code base where these improvement proposals are implemented ( https://github.com/dashpay/dash ). For the second method
so:
I would not like to have 2 fork in the consumer code (js)
it's easy to do only after you have added DIP2 to js ( UdjinM6/bitcoinjs-lib@69807fd )
very strange for this PR @UdjinM6 @codablock |
Well, that's debatable imo. The output json data is 10-ish times larger than the raw one, so for a full 2mb block you'll have to parse 20mb-ish json. And without patching bitcoinjs-lib you'll have to avoid parsing/producing raw data at all times and would have to only rely on workarounds instead, which throws quite a bit of bitcoinlib-js functionality out of the window imo.
Not really. The way I implemented it, it should be backwards compatible with bitcoin/litecoin/etc. so you only need just 1 single fork with these features implemented.
That's a good point. Maybe we could maintain such a fork in dashpay or dashevo repo. Thoughts @codablock @nmarley ? |
only when a new block arrives The good side of this approach is that the logic of obtaining useful data will lie entirely on the code base of dash core, which already contains all the code for work and does not need to be tied to third-party code (bitcoinjs-lib)
if (tx.version === 3) {
tx.extrapayload = readVarSlice()
} what if a litecoin or bitcoin transaction appears with |
True, good point. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
Add missing versionHex field (dashpay/dash@e7d9ffa) Change to use verbosity syntax (dashpay/dash#2506 and bitcoin/bitcoin#8704)
* Content - RPC - Update quick reference * RPC - Update getblockchaininfo to show BIP-9 progress Related to dashpay/dash#2435 * RPC - Update gobject prepare with new params Use-IS (dashpay/dash#2452) Use specific UTXO for fee (dashpay/dash#2482) * RPC - Update mode name * RPC - Update protx default mode dashpay/dash#2513 * Content - Add spork 17 * Content - Special transactions Add info for Quorum commitment Remove messages not in 13.0 (SubTx) * P2P - Add new txlvote fields masternodeProTxHash (dashpay/dash#2484) quorumModifierHash (dashpay/dash#2505) * RPC - Update protx list Make all options follow the same parameter format (dashpay/dash#2559) * Content - version bump 0.13.0.0 bumped to 70213 (dashpay/dash#2557) * Guide - PrivateSend dstx message limit Up to 5 simultaneous dstxs per MN allowed (dashpay/dash#2552) * RPC - Update getblock Add missing versionHex field (dashpay/dash@e7d9ffa) Change to use verbosity syntax (dashpay/dash#2506 and bitcoin/bitcoin#8704) * P2P - Add qfcommit message (no hexdump example) DIP6 quorum final commitment (dashpay/dash#2477) * P2P - qfcommit typo Change description of llmqType field * P2P - Special tx payload size clarification * Guide - Update MN payment description Related to dashpay/dash#2258 * Guide - fix broken link * Guide - Update some example txs Change to hashes on the chain following the 12.3.4 reset * P2P - Add QcTx hexdump * P2P - DIP4 message updates Add SML entry Update hexdump to include new fields Add getmnlistd and mnlistdiff to cross ref * P2P - minor DIP3-related comments
No description provided.