Verify Bitcoin Transaction

Following the great post [Redeeming a raw transaction step by step example required, I came up with code below but the verification failed.

// pubkeyBytes, len: 65
// 042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9

// data, len: 32
// 30f10a6468b7d98257af63fb40dfcf2cefe991346fd37c67cf7b51ff8d4404d3

// signatureBytes, len: 71
// 30450220587ce0cf0252e2db3a7c3c91b355aa8f3385e128227cd8727c5f7777877ad772022100edc508b7c14891ed15ab38c687019d7ebaf5c12908cf21a83e8ae57e8c47e95c

    ECPublicKey publicKey = (ECPublicKey)KeyBuilder.buildKey(KeyBuilder.TYPE_EC_FP_PUBLIC, KeyBuilder.LENGTH_EC_FP_256, false);;
    publicKey.setW(pubkeyBytes, (short) 0, (short) pubkeyBytes.length);

    Signature eccSign = Signature.getInstance(Signature.ALG_ECDSA_SHA_256, false);
    eccSign.init(publicKey, Signature.MODE_VERIFY);
    boolean verified = eccSign.verify(data, (short)0, (short) data.length,
                signatureBytes, (short)0, (short)signatureBytes.length

Assertion failed at the end.

Have been stucked for hours. Cannot figure it out. Any help is highly appreciated. Thanks.

why using `blockIndex` in bitcoin’s code `unconfTxs`

I am reading the code of rpc’s estimateSmartFee method , and I can’t understand why using blockIndex in unconfTxs ?

estimateSmartFee loop unconfTxs to get feeRate(code:

But the value unconfTxs[blockIndex][bucketindex] will be reseted in TxConfirmStats::ClearCurrent or reduced in TxConfirmStats::removeTx.
Why not just define like this unconfTxs[bucketindex]?

source file fees.cpp

unsigned int TxConfirmStats::NewTx(unsigned int nBlockHeight, double val)
    unsigned int bucketindex = bucketMap.lower_bound(val)->second;
    unsigned int blockIndex = nBlockHeight % unconfTxs.size();
    return bucketindex;

the unconfTxs

    // Mempool counts of outstanding transactions
    // For each bucket X, track the number of transactions in the mempool
    // that are unconfirmed for each possible confirmation value Y
    std::vector<std::vector<int> > unconfTxs;  //unconfTxs[Y][X]

How do I recover from a cryptocurrency scam?

I lost about $45,000 to crypto investment scam just recently. The
company posed as an investment company that could deliver a certain
percentage in returns if you deposit your Bitcoin with them. At first, it
seemed real, it worked twice. I didn’t realize they set up a bot(robot)
that will completely shutdown your account after you have decided to invest
high. I suddenly couldn’t access my profile, I complained to the admin, he
gave a excuses that they had a downtime and needed to upgrade their
website, this took over 2 months. Within that period,I begin to suspect i
have been scammed. I contacted my bank to see if they could do anything about this situation, they couldn’t. Local police say it’s impossible to get my money back.

Can anyone help me ? This has made me really frustrated as I invested all my savings.

Bitcoin protocol and Wireshark

I captured bitcoin protocol communication in real-time and it is present in fig1 and fig2.

enter image description here

In red box, there are many types of command.

First Question:

How can Wireshark detect bitcoin communication and parse them? I think
the packet that socket sends may have something what I don’t know.

In red box of fig2, you can see many properties of packet. this is definitely defined by software program, not hardware such as router. Real data that client send is really just hex data which is encoded by specific rule.

Second Question:

How Wireshark can parse data received? Bitcoin client can parse it because they know the rule but Wireshark doesn’t know anything since Wireshark is thrid-party program, which no have any relation with Bitcoin software.

enter image description here

Sorry for my English.

How to install Berkeley DB 4.8 on Linux?

The Unix build notes do not show how to install version 4.8 apart from saying

BerkeleyDB is required for the wallet. Ubuntu and Debian have their
own libdb-dev and libdb++-dev packages, but these will install
BerkeleyDB 5.1 or later. This will break binary wallet compatibility
with the distributed executables, which are based on BerkeleyDB 4.8.If you do not care about wallet compatibility, pass –with-incompatible-bdb to configure. Otherwise, you can build from self-compiled depends (see above).

The referenced from the quoted

Now, you can either build from self-compiled depends or install the
required dependencies:

does not discuss BerkeleyDB 4.8.

I know there is ./contrib/ in the source for installing BerkeleyDB 4.8 but it abords on my Ubuntu with curl: (7) Failed to connect to port 443: No route to host.

How to connect LND to bitcoind RPC with authentication cookie stored in a custom folder?

I configured bitcoind RPC to authenticate clients with an authentication cookie. However I cant figure out if it’s possible to use this method with lnd while connecting to bitcoind RPC.

I would like to clarify that I’m running bitcoind and lnd in two separated docker containers that share a volume where bitcoind save the authentication cookie. The problem is that lnd doesn’t allow to specify the folder in which it could find the cookie… In bitcoin.conf for exemple you can specify the path where you can find the authentication cookie of the tor control port for example…

Someone knows how to do this in lnd ? Is it possible ?

Thank you!