bitcoin-cli 命令参数中的详细程度是什么?

问题描述 投票:0回答:2

我遇到过一些

bitcoin-cli
命令,其中需要额外的详细程度参数来获取有关该命令的其他信息,例如
getblock “blockhash” ( verbosity )
需要 0、1 或 2 的详细程度值。
什么是冗长,它有什么作用以及如何使用?
这是你在配置中设置的吗?

bitcoin bitcoind
2个回答
1
投票

详细程度是指提供的信息量和细节。正如

getblock
的文档所述:

如果详细程度为 0,则返回块的序列化、十六进制编码数据的字符串 ‘哈希’。
如果详细程度为 1,则返回一个包含有关块信息的对象。
如果详细程度为 2,则返回一个对象,其中包含有关块的信息和有关每个交易的信息。


0
投票

在较新的比特币核心节点版本上,详细程度为 3,这将为您获取输入的 UTXO,从而解析以前未提供的详细程度为 2 或更低的金额和输入地址。 但请注意,我过去见过比特币节点不会为 P2PK 地址生成地址,因此您可能还需要如下脚本来自己为这些边缘情况生成地址:

// will take a public key from a p2pk transaction and convert it to an address
function p2pkToAddress(pubkey) {
    // working example: http://gobittest.appspot.com/Address
    // parse hexa
    let pk = Buffer.from(pubkey, "hex");
    // hash the pubkey with SHA256
    let firstHashSha256 = crypto.createHash("sha256");
    firstHashSha256.update(pk);
    // hash the sha256 with ripemd-160
    let secondHashRipeMD = crypto.createHash("ripemd160");
    secondHashRipeMD.update(firstHashSha256.digest());
    // add network bytes 00 to the second hash
    let strHash2 = secondHashRipeMD.digest("hex");
    let secondHashWithPrefix = Buffer.from("00" + strHash2, "hex");
    // perform another sha256
    let thirdHashSha256 = crypto.createHash("sha256");
    thirdHashSha256.update(secondHashWithPrefix);
    // do it again
    let fourthHashSha256 = crypto.createHash("sha256");
    fourthHashSha256.update(thirdHashSha256.digest());
    // isolate the first four bytes of the 4th hash
    let fourthHashPrefix = fourthHashSha256.digest().slice(0, 4);
    let fourthHashPrefixStr = fourthHashPrefix.toString("hex");
    // concatenates first 4 bytes of fourth hash with the secondHash with network prefix
    let combinedHashes = Buffer.from(secondHashWithPrefix.toString("hex") + fourthHashPrefixStr, "hex");
    // base58 encode the string
    let result = bs58.encode(combinedHashes);
    return result;
}
© www.soinside.com 2019 - 2024. All rights reserved.