text:
How long would it take to break a 32 bit key / encryption
I was actually wondering...
How long would it take to crack/brute force a 32 bit key/encryption and a 16 bit key/encryptions respectively?

I’m voting to close this question because it is better suited for crypto.stackexchange.com

And why did you actually do that... It's not ethical in any way... Don't you know that all Stackexchange websites are interwoven in a way that anyone can find an answer in just a search on any of their platforms... So what is actually your intention? For this question to be closed irrelevantly because you think it's "Suitable" for a section of this platform...  I'm PISSED.

@Dave Kent Please stay polite. We're not telling off, and people are even answering your question regardless. But this question is unrelated to Bitcoin, and you should post it on crypto.stackexchange.con - you'll get much better answers there too.

Way too fast.
It's only 4,294,967,296 combinations for 32 bit and 65,536 for a 16 bit. I assume it can be cracked in seconds/minutes by a high-grade consumer laptop.
The resources required for a brute-force attack grow exponentially with increasing key size, not linearly.
I would also suggest reading the article about breaking mnemonic seed where author had to calculate SHA-256, SHA-512, RIPEMD-160, EC Addition, EC Multiplication in every iteration and he was able to check ~143,000 mnemonics per second.

By high grade; what should be the criteria of the laptop? And are there any specific numbers in minutes or seconds that we're looking at?

This depends far more on exactly what encryption scheme is being used than on the CPU.

One can say the encryption scheme I'm going with is actually brute force. Does this still change the speed at which the bits are processed?

That makes no sense. Brute force is a mechanism for breaking encryption. You still haven't revealed anything about the scheme you're breaking.

"article about breaking mnemonic" There is no encryption in BIP-39


text:
Are there online cryptowallets where I can upload my wallet.dat to get my balance?
I have some wallet.dat files from the time I was fiddling with cryptocurrencies years ago.
Tried to open them using the wallet clients of each one, they load, but I have to download (and process?) the whole blockchain to know the actual balance, and it's taking a lot of time and disk space.
Are there any online services that already have the blockchain so I just load my wallet.dat to get my balance?
I know there are security risks about giving my wallet.dat, my idea is to then transfer the wallet balance to another online wallet like coinbase.
Any advice is welcome since I'm out of the loop.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
BTC payment sent and confirmed in blockchain but haven’t received in other wallet!
Help!! It was confirmed about 34+ times but this is the first time this has ever happened to me! Usually it’s a piece of cake or at least it’ll show up in my account as “pending” but I don’t see it as a deposit to my wallet AT ALL and it’s been over 6 hours. Plz help.
Transaction ID: 7e444a3d0c6425b72bb200d54fe9b85564bdac616b36da3ef81481571947f09c
Thanks in advance!
Celeste

Does this answer your question? Bitcoin successfully deducted on sender wallet but did not reach receiver wallet

There's nothing wrong with this transaction and there's nothing you can do to fix it. A common type of scam is to launch fraudulent exchange websites that don't even check if they received your payment. If you e-mail their support, then they might change your transaction to "processing" but then it'll be stuck at processing until they shut down the website.

Do I email the support where I sent the bitcoin TO? Or FROM?

You can e-mail them "This transaction [Transaction ID] pays [amount] to the address you gave me [recipient address]". (By the way, am I reading the question correctly: You've sent from your wallet to a company and not the opposite?)

I sent bitcoin from my CEX.IO wallet to my Cash App Bitcoin Wallet. Usually it posts within 5-10minutes. This time is hasn’t even showed up as received in my cash app.

Then you shouldn't write to CEX.IO support. Can you see the address Cash App generated in the the transaction, when you open it on a blockchain explorer?

Yes. I just checked it. This is what it says  I’ll add the photo to original question

Then you should contact the developers of Cash App Bitcoin wallet. It can be a bug.

I posted the photo. I’m not sure what it means though

Did you see the photo I posted ?

Yes, your coins should arrive if 19W2... is your address. I'm not familiar with Cash App Bitcoin wallet so I can't help further than suggesting to relaunch the wallet.

Don't worry, I've found that you're not the only person experiencing that problem. At https://www.reddit.com/r/CashApp/comments/gsqd2l/cashapp_wont_update_my_balance/ or more specificly https://www.reddit.com/r/CashApp/comments/gsni2d/megathread_missing_bitcoin_deposits_after/ it seems there's a problem at their end. You should receive your coins after it undergoes maintenance. Official announcement

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
What is the optimal way to increment extranonce?
I'm trying to learn how to block headers are created and an efficient way of doing so. Given a list .of transactions, can I change the extranonce without having to rehash the entire list?
EDIT: To clarify, I am not asking about what the extranonce is but whether there are algorithms to recompute the merkletree better than others.

If one has only one change in the Merkle tree the complexity to compute the hash is O(lg(n)) because other branches are hashes are reused. No further speedup is possible (except Asicboost) as even one bit change in coinbase transaction causes avalon effect.

Thanks! This answers the question. I take it that the coinbase Tx must go into the start then

The extra nonce is indeed additional space in coinbase. I don't see any reason why you cannot precompute all the extranonce fields. So, even the log(n) time could be amortized

I think you can get ln(n)/ln(2) with precomputation. But it is less if the coinbase tx didn’t go into the bottom.
And I guess it needs to go into the bottom?

Each transactions is a leaf at the bottom level of the Merkle tree.

The Merkle root of the transactions is calculated by building a binary tree from the transactions as leaves where each parent node is the hash of its two children. As the coinbase transaction is the first transaction in the block, you can store the hashing partners on the coinbase transaction's Merkle branch and only repeat all the hashes to which the coinbase transaction contributes. This reduces the required number of hashes to calculate the new Merkle root for n transactions from O(n) to O(log(n)) given that no other transactions in the block were changed.
There is no way around repeating the whole left flank of hashes in the binary tree, since changing the extranonce in the coinbase transaction changes the outcome of the bottom left hash combining coinbase transaction and first regular transaction.

The extranonce is a part of the coinbase transaction, inside the coinbase transaction there is an arbitrary data, and when you change this data, your merkle will change too

I ask about algorithms to achieve this efficiently, not what the extranonce is


text:
How does Bitcoin choose to which miner the reward will go?
Let's say 100 miners with similar hashrate all try at the same time to mine the same block and finish at the same time, how will Bitcoin choose to which miner the reward will go? Is there some prority protocol?

Time in bitcoin isn't precise nor reliable, every peer can have their own idea of time and every peer has a view of other peers time that lead a single peer to have knowledge about time drift (adjusted time).
Any miner can mine using past or even future timestamps but there are rules that enforce blocks to be generated not too much in the past (using the median time of previous blocks) and not too much in the future (using the adjusted time from your known peers)
Having said that, mining is a race, if many mine at the same time the network will have temporary different views based on peers and their neighborhood (e.g. if you are connected directly to a miner, you'll likely get first the block from it while if you have not direct connection to a miner but one of your peers does, you'll likely get the block from that miner too, basically it's about latency between nodes)
At that point your node have a view that will put one of these mined blocks as your TIP, if you are a miner and you succeed to find the next block before others add a block on other forks, you'll likely have a chance that your view will become the valid one for the rest of the network (if other big miners don't decide to ignore your block and try to mine on their own vision, in case they found the previous block and have incentives to do so)
Well, I understand my explaination isn't probably easy to follow because there are lot of nuances behind, in any case the short ELI5 answer is: when multiple miners mine a block at the same time, the network will sort it out waiting for the longer chain to emerge from forks.
EDIT
P.S.
note that when all of them mine, all of them get the reward in their own view, because all of them think to be on the tip of the chain.
But only one of these blocks will survive because the longest chain based on these forks will become the valid one and so other miners will have to rollback their own view up to the fork point (so losing the reward they thought they won) and moving to the now-valid chain

It's all about probability. In about 10 minutes, a miner among those 100 will finally achieve to solve the proof of work for the given block before others will. So, he then will write that block on the blockchain, using it's address in the receiving address field of the coinbase transaction, thus obtaining it's reward.
what happen if they all mine the block at the same time
In that case, the blockchain would be temporary forked on the block at height X, given X the number of the block been mined at the same time by more than one miner. This won't last forever. Remember the golden rule of bitcoin: the longest chain win. Among those forks, one will definitely be resolved (again, it's all about probability at the end of the day), meaning more hashrate will be brought to it, so it will grow faster (speaking about blockheight) than the other. That one will become the current blockchain.
What happens to the other forks? Well, they're simply not valid blockchains. They contain outdated data. If forking miner continue to mine on those blockchain, they'll do at a lost, because they will get rewards on a blockchain which is not the main one
Is there some priority protocol? No, absolutely. Just probability. The more hashrate you have, the more probably you can mine the next block
how the precise time of completion is calculated (is it using the miner's computer clock as timestamp? From the bitcoin wiki

A timestamp is accepted as valid if it is greater than the median
timestamp of previous 11 blocks, and less than the network-adjusted
time + 2 hours. "Network-adjusted time" is the median of the
timestamps returned by all nodes connected to you. As a result block
timestamps are not exactly accurate, and they do not need to be. Block
times are accurate only to within an hour or two.Whenever a node connects to another node, it gets a UTC timestamp from it, and stores its offset from node-local UTC. The network-adjusted time is then the node-local UTC plus the median offset from all connected nodes.

I edited my question to ask more precisely about wht happen if they all mine the block at the same time. Is there some priorioty protocol? I also wonder how the precise time of completion is calculated (is it using the miner's computer clock as timestamp?).


text:
How to determine broadcast timestamp and confirmation timestamp for a given transaction id?
Given a transaction ID, how can I get:

The timestamp that the transaction was first broadcast
The timestamp that the transaction was first confirmed

In this case, I sent the transaction -- so I have access to the wallet that signed & broadcast the transaction. This week bitcoin transaction fees have been absurd ($20 for priority), so I sent it with a very low transaction fee, knowing it may take many hours or days to confirm (still faster & cheaper than a fiat Wire transfer).
Finally, the transaction did confirm, but I'm not sure exactly how many hours it took.
When I right click on the transaction and select View Transaction in the Electrum wallet, I see a Date field that appears identical to the timestamp visible on public blockchain explorers -- so I'm pretty sure that's the timestamp that the transaction was confirmed (or, rather, the timestamp in the header of the block that first included this transaction -- which was accepted by the network and is more or less precise).
But where in electrum (or otherwise) can I see the timestamp that the transaction was first signed/broadcast?


text:
Do BTC transactions also transfer funds of sister currencies that were forked from the BTC blockchain?
If I mined some bitcoin before the bitcoin blockchain was forked and I transfer those bitcoins to another bitcoin wallet after the bitcoin blockchain was forked, does that also transfer the "sister" altcoin? Or does it only transfer the btc?
For example, let's say I mined a block on January 1st, 2010. I received 50 bitcoins as a reward, and I let them sit in cold storage for 10 years.
On January 1st, 2020, I want to sell my 50 bitcoins, so I buy a pizza pizza franchise for 50 BTC. I send the 50 BTC from my regular bitcoin wallet to the seller's bitcoin wallet.
Did I just transfer BCH (Bitcoin Cash) and BTG (Bitcoin Gold) -- two cryptocurrencies that forked off of the BTC blockchain in 2017 -- to the seller?

In theory, it depends. A fork could be constructed in such a way that transactions on one side of the chain can be "replayed" on the other side, in either direction, or in both.
This is however not the case for the forks you mention, or any high-profile ones that actually went through. So transacting after the fork on one side does not move coins on the other.


text:
List of popular protests and revolutionary movements that accepted permissionless cryptocurrency to avoid donation censorship?
Where can I find a list of historically-important protest and revolutionary movements that accepted bitcoin (and/or other permissionionless cryptocurrencies) as a result-of (or to preempt the risk-of) financial blockades and their accounts being frozen?
The first bitcoin wallet I ever created was in late 2011. I learned about Bitcoin as part of the Occupy Wall Street movement. As a permissionless currency, we used Bitcoin to accept donations that couldn't be blocked by the financial institutions (the same financial institutions that we were actively protesting and demanding criminal justice against their leadership). It made sense.
Even though this history is apart of living memory, I struggle to find sources of information online pinpointing the exact date Occupy Wall Street started accepting bitcoin, and why.
It's very sad that this history is being muddled. Especially because today, more-and-more people think that that Bitcoin was created as an investment vehicle for capitalists without understanding the history (that it was created as an egalitarian alternative currency, not a capital asset).
Where can I find a curated, well-referenced list of all the protest movements that accepted Bitcoin, including Occupy Wall Street?

occupywallst.org added bitcoin to their donation page on Nov 26, 2011 https://web.archive.org/web/20111126164538/http://occupywallst.org/donate/

#FeedTheProtest published their bitcoin address on Sep 27 2011 in response to PayPal blocking withdrawals of their donations https://web.archive.org/web/20111004164350/http://feedtheprotest.com/node/223


text:
Unable to return BlockHashes when I run this generatetoaddress
I have downloaded and fully synced with my Mac last Saturday, my Bitcoin Core version is v0.21.0 and my Bitcoin-Qt version 5.9.8.
I did run other RPC commands such as "getrpcinfo" and it did provide result:
{
"active_commands": [
{
"method": "getrpcinfo",
"duration": 72
}
],
"logpath": "/Users/jsjs77/Library/Application Support/Bitcoin/debug.log"
}
"getbalance" -
￼
{
"mine": {
"trusted": 0.00000000,
"untrusted_pending": 0.00000000,
"immature": 0.00000000
}
}
But then, when I want to run this "generatetoaddress nblocks "address" it does not provide block hash result:
￼
generatetoaddress 11  1MDihWw2UfkYyAwrQDWNFbmaH6bx4NBFtL
￼
[
]
I have tried the following methods:
bitcoin-cli generatetoaddress 11  1MDihWw2UfkYyAwrQDWNFbmaH6bx4NBFtL.
￼
Method not found (code -32601)
and
bitcoin-cli -regtest generatetoaddress 11 1MDihWw2UfkYyAwrQDWNFbmaH6bx4NBFtL
￼Method not found (code -32601)
Is this got to do with the changes of latest version? I really need help. Thanks


text:
How to create a valid BTC Block?
I know Javascript is not the Language for this matter, however i believe it's the easiest to understand and would be very easy to anyone to port to any other language.
what i am trying to understand is how do i "hash" transactions, "create my own 12.5" transaction concat, append, rehash, hash it once again... as i see here and there...  it all seems very confusing, anyone could explain a bare basic implementation of step by step on what is needed in order to create a valid btc block?
my ultimate goal is to get any random block here https://blockexplorer.com/, and using the exactly same nonce as input recreate the same result

This article may answer your question.

Your question involves quite a bit.
Mining is done with conjunction of a wallet.
A lot of the work is handled by the wallet.
See the RPC getblocktemplate
Also run help getblocktemplate to see more information, that will point you to a few BIPs (B22, 23, 9, and 145) for further reading.
Basically (simplified) you do a getblocktemplate and then you repeatedly hash it (while incrementing the nonce) to get a hash that meets the difficulty criteria.
I hope this is enough information to get you started

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Is it possible to avoid a ~$40 fee for a 220-input transaction?
I want to transfer all my BTC from my old Electrum wallet to a new one, so that I can claim Bcash using Electron Cash without risking losing my BTC. The problem is that my ~0.143 BTC came from hundreds of transactions (cloud mining, faucets, etc.) and even with the lowest fee on the Electrum slider (confirmed within 25 blocks), the total fee is 0.013 BTC!
Is there any way I can avoid such a huge fee, while ensuring that my money is sent. There is a 'replaceable' fee option in Electrum. Does that mean that I could try to set the fee/kB very low and up it if nothing happens, without risking my BTC getting lost?
UPDATE: I sent a transaction off with replaceable fees at ~8 satoshi/byte, thinking that there was nothing to lose. It was confirmed in less than an hour :-)

Can anyone help me with this? If so, I would very much appreciate it.

not sure, what Bcash or Electron Cash plays as role here. Still, I believe this can be done. https://bitcoinfees.21.co/ shows that fees are fairly low currently. You should try to export keys from your old electrum wallet, and load them into a new Electrum wallet (then you don't need to "transfer"), and go from there. The newer version allows to set tx fees in Saoshi/Byte. Alternativly, there are command line tools (a bit more complicated), that allows to assemble a tx, and send it to the network. Question is, how much effort you wish to invest for 40$ ...

Thanks for the reply. The Bcash reference was just for background - it's simply a question of transferring all this BTC from one wallet to another. If I ever use my bitcoins, which I'm sure I will someday, I guess I'm going to need to do a transfer like this, so I might as well do it now. The tx is 32604 bytes (!), with the lowest fee suggested by Electrum at ~39.8 satoshi/byte.

Not sure, how low you can go with latest Electrum wallet, I last recently  created manually a tx (c9908124e59a2794f3807b366be7d235ff7654251adcdf396e209236341b3c32) with 20 Satoshis per Byte, having a size of 18KBytes. Later on I went down to 10 S/Byte, and I heard from people they did 5 S/Byte. If you are interested, and on OpenBSD or Linux or MAC, you could give it a try with these shell scripts: https://github.com/pebwindkraft/trx_cl_suite (you don't want to provide your private keys or similiar to anyone).

You've overpaid. 1 satoshi per byte is enough today

@pebwindkraft: Comments are meant for seeking clarification, providing constructive criticism, or leaving transient post-it notes, however, you're answering the question. Please don't post answers in the comments. Could you please take the essential parts of your comments and post them as an answer?

wait for scaling technology to catch up...
fees will decrease at some point in the future

bitcoinfees.21.co shows that fees are fairly low currently. You may try to export keys from your old electrum wallet, and load them into a new Electrum wallet (then you don't need to "transfer"), and go from there. The newer version allows to set tx fees in Saoshi/Byte.
Alternativly:
If you are on OpenBSD, Linux or MAC, you could give it a try with these shell scripts: github.com/pebwindkraft/trx_cl_suite (you don't want to provide your private keys or similiar to anyone!).
I used the tools last recently to create manually a tx (c9908124e59a2794f3807b366be7d235ff7654251adcdf396e209236341b3c32) with 20 Satoshis per Byte, having a size of 18KBytes.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Is it possible to write a transaction of bitcoins, having only pen, paper and a private key from the address with some unspent outputs?
In my last answer I have done an allegation which I want to be proven or disproven. If this work possible, how much paper does it require? What kind of software needs Bob to send a transaction to miners?

You can write a transaction by hand. You'll definitely need to use a computer to sign it. Then you can then search for "Bitcoin push transaction" to broadcast yours, or you can connect to a node with TCP and send them the transaction, or you can mail the signed transaction to your favorite pool operator.

The transaction digest alone would take around 2 days of non-stop work:
http://www.righto.com/2014/09/mining-bitcoin-with-pencil-and-paper.html
That's before you even start the 32-byte multiplication required to compute an ECDSA signature.
It might be humanly possible if the UTXO you are spending does not require a signature. An "anyone-can-spend" transaction would only take a few minutes to assemble since they require no input script. But then of course anyone could steal your coins before your TX got confirmed.


text:
Full node or Full node third-party services pros and cons
I'm setting up P2P Bitcoin website similar to LocalBitcoin for school project.
Before I go deep into this journey I'm doing some plannings.
I have lot's of questions in my head and have been studying bitcoin technology.
I would like know if its better to run full node on my server and execute RPC commands or should I just look for companies that offer such services to save me some time?
What are the  pros and cons of running full node
I will also appreciate recommendations for third-party services for Bitcoin P2P market

What are the pros and cons of running full node

it all comes down to the level of trust. Whom do you trust? Your own system, or someone else? And then, how much money are we talking about? Several low values, or monthly or yearly values?
For sure I recommend a full node. And yes, it has the disadvantage of downloading the blockchain (easily up to three weeks), and you need to have that infrastructure up and running. For this you gain the absolute security, that noone faked a block or a tx in the blockchain, that is assembled on your system. Also the level of privacy is higher than e.g. SPV nodes. A full node supports the decentralization aspects of the network. More full nodes, more tamperproof is the whole bitcoin eco-system.
Using RPC calls to your local bitcoin node requires then some developer knowledge, or a dev-team. That can add to costs in setting up your environment.
Using services like bitpay or similiar has the advantage of getting quickly started. This way you can start to setup your business, and later on, if you have really big values, you are still able to convert to a full node.
So from a risk perspective: when it is low values, go ahead with services from third parties, but when you achieve higher values (above monthly income), think about securing your environment with an infrastructure, that is under your own control.

Thanks a lot for your answer. I was told exactly same thing when I asked in Bitcoin irc chatroom. Since then I have gained more knowledge and have built an API that talks to my full node using rpc. Thanks

There is no company offering reliable full node services(i.e. they have various rate limits). Best is to use your own node. Unfortunately the bitcoin nodes suck big time(i.e. bitpay insight is broken, bitcoind indexes only one address/wallet etc) so you will have to build a lot from scratch. If bitcoin is not a hard requirement I suggest you to look for a "localethereum" project. Ethereum has better software.


text:
How to get fee in a transaction with unconfirmed inputs in bitcoinj?
I am trying to get the fee of incoming transactions in a wallet with bitcoinj. At times it was the commission using Transaction.getFee(), but this was throwing NullPointerException. I got to do a little more research and I realized that it happens when the transaction has unconfirmed inputs. I've tried adding the value of all the inputs and subtracting the value of all the outputs, so you would get the fee, but on these occasions the sum of the inputs is 0 BTC. Is there any other way to get the commission?
I leave an example of the output of one of the transactions (testnet):
04f570fdd0cb8c973d8c9b3adf09b803ef70941ec239685d479a93b089e4d621: Seen by 1 peer. Pending/unconfirmed.
   in   PUSHDATA(72)[3045022100fe750e43c3bc46eddb390dad98acd6ef0646e00386770de542e7e5c581f8118102206924cd243b459645ae8626e948e1d33404d29c651a8a59c24ed5cd902d7e939201] PUSHDATA(33)[02a40db91b59058375fe7f13810beb6609e63a8974ce355b76d01692058eaac9f9]
        outpoint:7cd4378560d2b36f53b3d492afa815c5ae615d18bff9611c3081f591a1c0c156:0
   out  DUP HASH160 PUSHDATA(20)[49d2661baf33597c6dc3dbdbb9e7a8835fdb76b4] EQUALVERIFY CHECKSIG 0.00126081 BTC
   out  DUP HASH160 PUSHDATA(20)[372fb0d8affe634b369af9722cc48c63ad90e9df] EQUALVERIFY CHECKSIG 0.001 BTC
   prps UNKNOWN

In case of a SPV node you don't have the values of the inputs of a transaction, as you don't have the full blockchain and thus all the UTXOs.
The transaction itself has no values of the inputs!
You have the following options:

Query a trusted server for the UTXOs (e.g. electrum servers)
Query a webservice (e.g. blockcypher)
of course have a full copy of the blockchain, you could use java bindings to query a local bitcoind


text:
How to get balance from a specific address in bitcoinj?
I'm trying to get the balance of a specific address in a wallet by using bitcoinj, but I don't know how. Can someone help me? Thanks in advance!!

This has been flagged as "Unclear what you’re asking", can somebody explain why? I don’t know enough about bitcoinj to be certain whether it would be useful to the asker’s issue.

this is very clear and usefull question

I found the solution for this question. I used this class:
/**
 * This class implements a {@link org.bitcoinj.wallet.CoinSelector} which attempts to select all outputs
 * from a designated address. Outputs are selected in order of highest priority.  Note that this means we may
 * end up "spending" more priority than would be required to get the transaction we are creating confirmed.
 */

public class AddressBalance implements CoinSelector {

    private Address addressToQuery;

    public AddressBalance(Address addressToQuery) {
        this.addressToQuery = addressToQuery;
    }

    @Override
    public CoinSelection select(Coin biTarget, List<TransactionOutput> candidates) {
        long target = biTarget.longValue();
        HashSet<TransactionOutput> selected = new HashSet<TransactionOutput>();
        // Sort the inputs by age*value so we get the highest "coindays" spent.
        // TODO: Consider changing the wallets internal format to track just outputs and keep them ordered.
        ArrayList<TransactionOutput> sortedOutputs = new ArrayList<TransactionOutput>(candidates);
        // When calculating the wallet balance, we may be asked to select all possible coins, if so, avoid sorting
        // them in order to improve performance.
        if (!biTarget.equals(NetworkParameters.MAX_MONEY)) {
            sortOutputs(sortedOutputs);
        }
        // Now iterate over the sorted outputs until we have got as close to the target as possible or a little
        // bit over (excessive value will be change).
        long totalOutputValue = 0;
        for (TransactionOutput output : sortedOutputs) {
            if (totalOutputValue >= target) break;
            // Only pick chain-included transactions, or transactions that are ours and pending.
            if (!shouldSelect(output)) continue;
            selected.add(output);
            totalOutputValue += output.getValue().longValue();
         }
        // Total may be lower than target here, if the given candidates were insufficient to create to requested
        // transaction.
        return new CoinSelection(Coin.valueOf(totalOutputValue), selected);
    }

    static void sortOutputs(ArrayList<TransactionOutput> outputs) {
        Collections.sort(outputs, new Comparator<TransactionOutput>() {
            public int compare(TransactionOutput a, TransactionOutput b) {
                int depth1 = 0;
                int depth2 = 0;
                TransactionConfidence conf1 = a.getParentTransaction().getConfidence();
                TransactionConfidence conf2 = b.getParentTransaction().getConfidence();
                if (conf1.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)
                    depth1 = conf1.getDepthInBlocks();
                if (conf2.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING)
                    depth2 = conf2.getDepthInBlocks();
                Coin aValue = a.getValue();
                Coin bValue = b.getValue();
                BigInteger aCoinDepth = BigInteger.valueOf(aValue.value).multiply(BigInteger.valueOf(depth1));
                BigInteger bCoinDepth = BigInteger.valueOf(bValue.value).multiply(BigInteger.valueOf(depth2));
                int c1 = bCoinDepth.compareTo(aCoinDepth);
                if (c1 != 0) return c1;
                // The "coin*days" destroyed are equal, sort by value alone to get the lowest transaction size.
                int c2 = bValue.compareTo(aValue);
                if (c2 != 0) return c2;
                // They are entirely equivalent (possibly pending) so sort by hash to ensure a total ordering.
                BigInteger aHash = a.getParentTransaction().getHash().toBigInteger();
                BigInteger bHash = b.getParentTransaction().getHash().toBigInteger();
                return aHash.compareTo(bHash);
            }
        });
    }

    /** Sub-classes can override this to just customize whether transactions are usable, but keep age sorting. */
    protected boolean shouldSelect(TransactionOutput output) {
        Address outputToAddress = output.getScriptPubKey().getToAddress(addressToQuery.getParameters());
        try {
            // Check if output address matches addressToQuery and check if it can be spent.
            if(outputToAddress.equals(addressToQuery)) {
                if(output.isAvailableForSpending()) {
                    return isSelectable(output.getParentTransaction());
                }
            }
         } catch (Exception e) {
            e.printStackTrace();
         }

         return false;
    }

    public static boolean isSelectable(Transaction tx) {
        // Only pick chain-included transactions, or transactions that are ours and pending.
        TransactionConfidence confidence = tx.getConfidence();
        TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
        return type.equals(TransactionConfidence.ConfidenceType.BUILDING) || type.equals(TransactionConfidence.ConfidenceType.PENDING) && confidence.getSource().equals(TransactionConfidence.Source.SELF) && confidence.numBroadcastPeers() > 1;
    }
}

EDIT: Use Wallet.getBalance(CoinSelector). Example:
Coin addressBalance = wallet.getBalance(new AddressBalance(myBtcAddress));

How do you use such code ? Don't see any method Coin getBalance(Address a)

@PavelNiedoba use Wallet.getBalance(CoinSelector). Example:
Coin addressBalance = wallet.getBalance(new AddressBalance(myBtcAddress));

Seems this is not useful anymore. Always returns 0.0 balance all the time at the year 2021 with the bitcoinj-core 0.15.10

public static void main(String[] args) {
    NetworkParameters params = TestNet3Params.get();
    String filePrefix = "peer2-testnet";
    WalletAppKit kit = new WalletAppKit(params, new File("."), filePrefix);
    // Download the block chain and wait until it's done.
    kit.startAsync();
    kit.awaitRunning();
    String ads = "n1XZMMm3ikh97Mr8JVnnahfugad2DRcVrB";
    Address address = new Address(params, ads);
    Wallet wallet = new Wallet(params);
    wallet.addWatchedAddress(address, 0);
    System.out.println("wallet.getWatchedAddresses()"+wallet.getWatchedAddresses());
    BlockChain chain;
    try {
        chain = new BlockChain(params, wallet,
               new MemoryBlockStore(params));

    PeerGroup peerGroup = new PeerGroup(params, chain);
    peerGroup.addPeerDiscovery(new DnsDiscovery(params));
    peerGroup.addWallet(wallet);
    peerGroup.start();
    peerGroup.downloadBlockChain();
    Coin balance = wallet.getBalance();
    System.out.println("Wallet balance: " + balance);
    } catch (BlockStoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

I tired this one and it worked but  each and every  time it is taking time to download the blockchian


text:
Multiple public keys - Total received funds
If I create a new public key (Bitcoin Address) for every transaction I'm receiving, is there some way to find my total balances of my wallet/private key?
And are there any downsides with creating unique addresses for every transaction?
Just to make it clear. I'm not talking about total balances in the wallet's GUI. I'm asking if there is some way for thirdpart who is watching transactions on blockchain.info to calculate my total balances in the wallet.

Are you asking for a specific wallet or in general?

If you're running Bitcoin Core as your wallet, then the graphical interface is handling your wallet's total balance already, which includes the balance of every address within your wallet.
If you prefer the command line method, use bitcoin-cli getbalance to get the total sum of all transactions in your wallet. That command basically balances your wallet transaction history like a checkbook, so including deposits and debits, and delivers you the final balance.
The balance shown in the Bitcoin Core GUI is the same as the balance displayed with bitcoin-cli getbalance.
To answer your second question, as far as I can tell there is no downside to creating unique addresses for every transaction, and in fact it is highly recommended in order to aid in anonymity. The fact that you own all of the Bitcoin associated with a particular wallet is harder to determine when more than 1 address is used to receive funds.
However, spending the entire balance of multiple addresses in a single transaction could negate any protection you were hoping to have by using multiple addresses in the first place, since an attacker could then determine, using that single transaction ID, that the total balance of the multiple addresses was associated with the same wallet.
Hope this helps
EDIT
One important note when creating many unique addresses is, if using the Bitcoin Core wallet, backups would need to be created more frequently because new private/public keypairs are generated when creating a new address, and previous backups will not contain the new keypairs. Therefore, if you create a backup of your wallet, then create a new address and receive 1BTC at that address, then your wallet backup will not contain the address that received 1BTC.

I think I wasn't clear enough in mye question. I have done a edit of the question.

I think the secondary part of my answer addresses that concern already.
"[Using a unique address for each transaction] is highly recommended in order to aid in anonymity. The fact that you own all of the Bitcoin associated with a particular wallet is harder to determine when more than 1 address is used to receive funds."

If I create a new public key (Bitcoin Address) for every transaction I'm receiving, is there some way to find my total balances of my wallet/private key?

The addresses in the blockchain are only related if you use them together in a transaction. For example if you make a payment to someone and you use bitcoins from 3 addresses (A, B and C) from your wallet a third person can assume that all these addresses are from the same wallet/person (which is not necessarily correct!) ... and add the remaining to get the balance from those 3 addresses. If later you make another payment that uses addresses (B, C, D and E) a third party will deduce that D and E are probably also your addresses and add them to your total balance. Outputs can also be used for this but I won't expand to avoid over-complicating it. Statistical analysis can find most relations but requires dedicated people. That is why mixing is so difficult.
So, it can be done but it does require quite some work for trustworthy results.

And are there any downsides with creating unique addresses for every transaction?

Nowadays, most wallets are Deterministic Wallets (by the way, bitcoin core wallet is not). That means that they use some kind of seed to create all future key-pairs from. Having that seed you can recreate all key-pairs that you have or could possibly create in the future. You can backup that seed and be certain that you have a final backup for that wallet. Thus, no downsides for Deterministic (or Hierarchical Deterministic) wallets.
However, in a non-deterministic wallet (like bitcoin core wallet, aka shatoshi client) if you take a backup today and tomorrow you create a couple of new addresses those new address will not be in the backup. Thus the downside for non-deterministic wallets is that you need to create backups frequently to ensure that you have a backup of all your private keys.


text:
Verifying ownership of utxos
Is there any other way besides signing a transaction to verify ownership of utxos?

To 'own some bitcoins' is to own the private key that allows a UTXO to be spent, so your question can be refined to "how do you verify ownership of a private key that controls a UTXO?"
There are a few ways you could do this:

Sign a generic message with the key, such as "I am the owner of bitcoin address 1a5Ag23...."
Sign a transaction with the key, spending the coins to a new address (you could post the address prior to broadcasting the tx, to prove the coins are not just moving by coincidence)
You could show off the private key itself (but this is a very bad idea! The bitcoins probably would not remain yours for long...)

I disagree that owning BTC is equal to having access to private keys. Coinbase certainly does not own all the BTC they have keys for, for example.

@PieterWuille I guess it is helpful to differentiate between 'ownership according to the blockchain' and 'ownership according to legal/social contracts'. In any case, the UTXOs  Coinbase controls would not map perfectly onto user account balances, so we can't really point to a specific CoinBase-controlled UTXO and say "that one belongs to user x". Coinbase may be reputable and have intent to fulfill their duties as a custodial service, but sketchy exchanges that have exit scammed in the past help prove my point. If someone owes you $5 but hasn't paid it back, you don't own that $5. They do.

In this sense, perhaps it would be better to say 'Control of the UTXO', rather than 'Ownership of the UTXO'. I think that satisfies both of our arguments.

I think there's a difference between money owed (a debt) and custodial control. Even the sketchiest exchange doesn't own your money - you're perhaps making a bad business decision to risk having them control it, but it in no way makes the money owned by them. I think ownership is inherently a social construct, and not something described by the blockchain. The latter is just a way to reduce risk of having the wrong parties take control. It's even more complicated with UTXOs controlled by escrow or hashlocked contracts. These don't have a clear identifiable owner key even.

Nonetheless, the answer does not delve into ownership of BTC. Coinbase certainly has ownership of the private keys needed to sign for each utxo.


text:
How are utxos associated with a particular address?
Is there a way to add or associate utxos with a particular address without creating a transaction?

There's some typo or mistake in your question that's preventing me to understand it

I corrected the mistake

Is there a way to add or associate utxos with a particular address without creating a transaction?

No. UTXO stands for Unspent Transaction Output. The only operations on UTXOs are creating and spending them, and both of those operations involve a transaction.


text:
What Happened 12/30/17 Last Recieved Transaction into Bitcoin Core Wallet
I have found a different receiving address within my wallet that is not mine... at least I did not create it. It seems to me that all of my transactions are now going to this new address instead of into my wallet. is there anything that I can do to recover these missing or stolen transactions?
In the debug log file on 1/1/18 I found that Bitcoin 12.0 was restarted and this shortly after, among other things:

InitParameterInteraction: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1

Seems like someone got in and redirected my transactions. Am I paranoid or did I just get robbed?

I have found a different receiving address within my wallet that is not mine.

If it is in your wallet then by definition it is yours (unless you added it as a watch-only address which I doubt in this case).
It could be a change address, automatically generated by your wallet to receive change from another transaction you sent. Without more info it is hard to say though.
The -whitelistforcerelay=1 parameter is nothing to worry about, that only relates to the relay of blocks between peers and is nothing to do with your transactions or wallet.

I'm not sure but if it is "mine" as part of my wallet then I should still receive the mining transactions into my wallet periodically.... I tried to "choose" between the receiving addresses and could not.  If it is a change address then I would think that I would see the transactions within the wallet, but there is no evidence of activity for any address.... I am just not sure how to fix the problem.....

I'm not sure what you mean by "mining transactions". Can you see the transactions in your wallet? You said you found them in your wallet, you seem to be contradicting yourself

I found the different receiving addresses under the file tab in my Bitcoin core wallet.... there are sending and receiving addresses found there. As far as any transactions... the last one was on 12/30/17 and there has not been any since. prior to 12/30/17 transaction were received into my wallet about every 3 or 4 days from the mining equipment that I have.

In the debug window of Bitcoin Core under the information tab, I see that the "current number of transactions" within the memory pool is active and growing in number which tells me that my mining equipment is functioning and "processing" bitcoin transactions.

No, you are probably not mining, the number of transactions in the mempool grows because you are connected to the network. To mine you need specialized hardware

Well, I spent 1500 bucks on a mining machine that is still running with good and active connections to the network it just seems to be making money for someone else at the moment.. I don't know what's wrong that is why I am on here but I'm about to unplug it and move on.

Well yes if you have a miner then you will need to configure it to pay you, typically you mine for a pool and then the pool will pay you, make sure you set up your configuration correctly.

That is what I don't understand, It has been configured correctly and has been working with no issues for over a year and now all of the sudden has quit... I have not changed anything or done anything to alter the original configuration.... one day it's working, the next it's not.

@user80788 If you set everything up yourself you should make some checks. Check the mining pool configuration if you use one, ensure that it is paying to your address. Same thing with the miner. If someone else set it up for you then that could be the problem.

usually if your bitcoin was send to the wrong address, you can try undo it while it in the mempool but if it already added to the blockchain then u cant undo it.
this may causes by a virus i used to have where i copy an address and it just made an completely random address.


text:
BLOCKCHAIN.INFO NO TRANSACTIONS
Long story short. Can't see transactions from blockchain.info as blockchain.com is now the website.
Long story:
Created a miner in 2013. Mined it from BTC Gui... and had it sent to BLO.....IN.INFO was able to check my account via bloc...in.info .
One day, it went to zero.
I didn't know what to do. So I just assumed I lost it all.
Well. I logged on to the now BLO...IN.COM..... and it shows a zero balance. BUT WITH NO TRANSACTIONS.
I put in the mnemonic that I wrote down in 2013 to recover the wallet.... all it gives me is the PASSWORD... not the wallet ID. This is obviously a legacy wallet.
How do I recover this old account to see transactions from 2013?
Note:
I do not have wallet addresses from the miner to blo...ain.info
I do not have access to the miner
I want to see the transactions from 2013 and I want to try to see where this coin went just for peace of mind that I know it didn't just go to zero.
Thanks for any help.


text:
What does the sixth line in the output of the Bitcoin Core GUI RPC command "gettxoutsetinfo" mean?
An example of the output of this RPC command is as follows.
 1  "height":n,     (numeric) The current block height (index)
 2  "bestblock": "hex",   (string) The hash of the block at the tip of the chain
 3  "transactions": n,      (numeric) The number of transactions with unspent outputs
 4  "txouts": n,            (numeric) The number of unspent transaction outputs
 5  "bogosize": n,          (numeric) A meaningless metric for UTXO set size
 6  "hash_serialized_2": "hash", (string) The serialized hash
 7  "disk_size": n,         (numeric) The estimated size of the chainstate on disk
 8  "total_amount": x.xxx          (numeric) The total amount
}

What's the meaning of the sixth line "hash_serialized_2"? Whose hash is this referring to?

It is a hash of the entire serialized UTXO set. You can use to verify that a node's UTXO set is uncorrupted (by comparing it with another node that runs the same command, at the same height).
The _2 prefix is to indicate the hashing algorithm that is used. Earlier versions used a different algorithm that became very hard to support efficiently. It's just there so people don't expect the hashes to be comparable between old and new nodes.


text:
Broker locked bitcoin wallet
I have a problem.
IS this a massive scam?
I invested £3,000 all in all with digital-miners.com the trader kept telling me that I could w/d my money anytime with no problem. Today I was told by my trader that I was no longer going to be trading with them as ''there were too many investors'' and a blockchain broker or someone like that would ring me, when I kept asking my trader about transferring money, he just kept saying the other person would ring me and kept avoiding the question.
When the other person rang me they said I had the money/bitcoin in my account but would need to send 10% £3,700 in advance to get the £37,000 in my account and it was now in a locked wallet. I can still trade with the money as I tried, but he says I can't get the money or bitcoin without paying the fee to liquidate it. I told him I don't need him to liquidate it, he can just send the Bitcoin to my Exodus account, but he said he can't do that without the fee as it is now in a locked wallet.
Anyone can help with advice on this would be appreciated. It was not done consensually and I don't understand why a trader would just drop me like that with £37,000 in my account unless it is to try to scam me out of the £3,700 to try to get the £37,000 that will never appear.
UPDATE... The guy who rang me about liquidating my funds has now said Digital-miners.com would allow the money to be refunded back to my account if I took down the post I made on trust pilot.. he said they would ring me about it.. I am still waiting for the call.

There was no £37,000 you have been scammed. The scammer tricked you into using an account or wallet that showed fake amounts. It was a trick all along. There is no way to get that monet with or without a fee because you never owned that £37,000. Report to police but forget about recovering the money you already gave to criminals, move on.

Does this answer your question? Refunding of payments if scam, or I invested in Bitcoin mining or How to recover my lost money or How to unlock the private key and many many others.

digital-miners.com looks fake. Registered only 6 months ago, phone number in London but address in Dublin Ireland. You're wasting you time waiting for them.

If they have a UK number then you could try reporting them to the UK authorities?


text:
What SIGHASH flags does CoinJoin use?
What SIGHASH flags are used when constructing a CoinJoin transaction?

CoinJoin uses SIGHASH_ALL.
I initially found this confusing because I assumed the interface to CoinJoin a little less synchronized than it is. CoinJoin requires each participant to first specify a UTXO and a public key to pay out to.
Someone then constructs a partially complete transaction which makes use of those UTXOs and pays out to the public keys specified by the participants -- this transaction is "partially complete" because it doesn't yet have signatures which unencumber the UTXOs. Each participant then signs their input with SIGHASH_ALL, which prevents outputs from being manipulated after the fact.


text:
What is an obfuscation key?
This message appears in my debug.log:
2017-01-21 00:16:42 Opened LevelDB successfully
2017-01-21 00:16:42 Using obfuscation key for /home/<username>/.bitcoin/blocks/index: 0000000000000000

As does this:
2017-01-21 00:16:42 Opened LevelDB successfully
2017-01-21 00:16:42 Using obfuscation key for /home/<username>/.bitcoin/chainstate: <removed>

What is an obfuscation key used for?

See also https://github.com/bitcoin/bitcoin/issues/6613

Either accidentally or intentionally, the Bitcoin Core chainstate database (which is a LevelDB database directory containing the UTXO set at the current tip) used to occasionally trigger anti-virus software. It would recognize certain byte patterns in it, and automatically quarantine and scan the file, resulting in database corruptions.
This was resolved by making the software use an obfuscation scheme for the non-hashed data in it. The scheme is very simple - a randomly chosen (per database) 64-bit value that gets XORed into all values in the database. This is fast, simple, and so far, effective.


text:
What's the best way to introduce Bitcoin to the family and friends?
What's the best way to introduce Bitcoin to the family and friends?
Has anybody succesful experience in the topic?

What do you mean by 'best'? Best at convincing them to use Bitcoin, or best at educating them about it.

I guess both. Trying to find new ways to tell people without causing more confusion.

related: http://bitcoin.stackexchange.com/questions/336/what-is-a-good-way-to-concisely-explain-bitcoin

I don't know the best way. But what I do is talk about it all the time. And actually use the bitcoins. I mean purchase things with your bitcoin not trade with them on exchange networks.
I buy a new product with my bitcoins and use it in front of my friends and family. Those who are interested ask where I got it, and then ask how much I spent on it. My response is in bitcoins. eg it was just 0.10 bitcoins very decent deal. Or it is just 2 bitcoins.
I've found that when selling an idea of bitcoin by saying things like 0.10BTC is worth $60.00 today I tend to get strange looks. Like so you spend $60.00 on 10 cents? People have a hard time understanding concept of ForEx and values of money when comparing one currency with another. It is more successful when you buy something and explain that you purchased it with bitcoin.
Also Christmas is coming up. And I've made paper wallets loaded with bitcoins. And on the paper wallets I have a list of websites that accept bitcoins as payments. So it is like a gift card and it helps people get the idea of what bitcoin is.


text:
Bitcoin core does not have all unconfirmed transactions
I am running bitcoinqt and checking for new transaction for payments I made using getrawmempool. Payments were made NOT from/to the mentioned bitcoinqt wallet address.
As I see some my unconfirmed transactions never come to getrawmempool.
Is it expected result or I am doing something wrong?

Have you got the whole blockchain locally? Have you check number of connectioins to the network?

it says "8 active connections to Bitcoin network"
And yes, I have whole blockchain locally

8 active connections is suspected - should be more

I opened 8333 port and now have 13 active connections. Is it enough?

The case is the 8 connections are built-in client. If you have more means that client has ability to get new nodes. It's OK.

If transaction isn't in memory you won't get it https://bitcoin.org/en/developer-reference#getrawmempool

http://bitcoin.stackexchange.com/questions/33980/2-bitcoinqt-getrawmempool-returns-different-results

What version of Bitcoin Core? Are you seeing the transactions at all eventually in the wallet?

Yes, I see new transactions but missing some new transactions made from mycelium wallet. Also these missing transactions I see in blockchain.info but confirmations takes much longer then another which I can see in memory pool. Bitcoin Core version v0.11.2 (64-bit)

In general, mempools are not guaranteed to be the same node-to-node. The behavior of the reference client is that once mempools reach 300MB, the lowest fee tx's are thrown away.
It's possible your node has reached this limit (either because it's 300MB or because your default is much lower) or simply because you're connected to nodes that have the same limitation.


text:
BIP 44 is scanning external chain really enough?
When reading the BIP 44 proposal I stumbled upon this paragraph about address discovery:

We scan just the external chains, because internal chains receive only
  coins that come from the associated external chains.

Is it really enough to scan only the external addresses to recover the full transaction history? What if you are using the same wallet simultaneously on another device and it makes a new transaction using the internal (i.e. change) addresses as the only inputs?
Imagine having a new empty wallet and receiving 1 BTC to your first external address and making a 0.01 BTC transaction to somebody else subsequenly. The remaining 0.99 BTC (minus fee) would be sent to your first change address and subsequent transactions to other wallets could and would use as inputs only change addresses, so scanning the history of your external addresses when rcovering the wallet from zero would reveal only the first and second transaction you made with the wallet, not the subsequent ones.
Is it perhaps enforced to include an external address as a change address in the transaction if all the inputs are internal? What am I missing there?

I got it - the paragraph in the BIP 44 proposal I referenced is about "Account discovery" - i.e. discovering whether an account was used at all. It's not about used addresses discovery within the account which is another thing of course, and it apparently requires scanning the change addresses as well, given the example in the question. So I just misunderstood it.


text:
Can corrupted unspent transaction outputs list leading to higher than expected fee be seen as an actual threat?
Let's imagine, an attacker managed to corrupt your local list of unspent transaction outputs (or a blockhain explorer you use) in a way that certain unspent transaction outputs seem to hold less coins than actually. When you proceed to make a new transaction to send 1 BTC and load your list of unspent outputs, you happily take as an input an output that seemingly has 2BTC but actually it has 100 BTC, but you don't know it since you have fake information. Therefore you set your transaction outputs to be 1 BTC for the receiver and 0.99 BTC as change, believing to pay a fee of 0.01 BTC and you happily sign and submit that transaction. But to your big dissapointment, you find out the next day that you actually paid/lost 98 BTC as a fee! The attacker did not gain anything, but he made you lose a significant amount of BTC.
My point is that the transaction inputs in the serialized transaction cointain only the output index and hash of the transaction where the output comes from. But since you do not broadcast to the network, which size you believe the input to be - you can sign and submit a valid transaction despite not agreeing with it, had you known the actual size of the inputs involved.
I know - you can verify the hashes of the transactions where the inputs come from and if something seems off, reject the transaction, or the transaction will be rejected by the network, since it is not practically achievable to "crack" the transaction hashes, but I'm not sure if lightweight clients/hardware wallets actually verify the origin of unspent outputs and I have a suspicion that TREZOR, for example, does not do it, since in the protocol you just send the transaction inputs and outputs.
So can you tell me, how and if current lightweight clients and hardware wallets are protected against the attack described above?
A simple fix to the issue above would be including the amounts explicitly in the transaction inputs, so when you sign the transaction you say "I believe that input x has y coins and reject the transaction if you think this is not true", but currently there is no way to do this AFAIK.

Therefore you set your transaction outputs to be 1 BTC for the receiver and 0.99 BTC as change, believing to pay a fee of 0.01 BTC and you happily sign and submit that transaction. But to your big dissapointment, you find out the next day that you actually paid/lost 98 BTC as a fee! The attacker did not gain anything, but he made you lose a significant amount of BTC.

Indeed, this would work, and it is a known issue.

I know - you can verify the hashes of the transactions where the inputs come from and if something seems off, reject the transaction, or the transaction will be rejected by the network, since it is not practically achievable to "crack" the transaction hashes, but I'm not sure if lightweight clients/hardware wallets actually verify the origin of unspent outputs and I have a suspicion that TREZOR, for example, does not do it, since in the protocol you just send the transaction inputs and outputs.

Actually, they do verify this. For legacy transactions, you have to send the TREZOR all transactions whose outputs you are spending from, to prove the amounts involved.

A simple fix to the issue above would be including the amounts explicitly in the transaction inputs, so when you sign the transaction you say "I believe that input x has y coins and reject the transaction if you think this is not true", but currently there is no way to do this AFAIK.

That is indeed a solution, and that is one of the changes that were included in the SegWit protocol change. When spending a SegWit output, a new way to compute signature hashes is used, which explicitly includes the amount you're spending.
This means that if you would somehow lie to the hardware device about the amount being spent, the resulting signature would be invalid.
You can read more about this change in BIP 143.


text:
'The node is not in a connected state' error when trying to execute OP_RETURN transaction with NBitcoin
This is my first time trying out the NBitcoin library to create a transaction. I am trying to create an OP_RETURN transaction, but every time I try to execute the Version Handshake with the node I get the error: The node is not in a connected state.
This is self explanatory, but I've tried a number of what are considered reliable nodes.
I guess this is a four part question:

When attempting an OP_RETURN transaction in NBitcoin, is it necessary to add the miner fees into the TransactionBuilder manually?
Is there a way to use Node.Connect so it will just search for available nodes, rather than specifying a specific node?
Is it an issue that I have the OP_RETURN and not anything else? Do I need to create another output with no value and add the miner fees in order to send it? There are libraries in PHP, Python, and Javascript to do this, but I am trying to figure out how to do this with NBitcoin.
If I wanted to store the incoming hash in the OP_RETURN script, am I doing it correctly? The byte stream seems to be too long.

Heres my code, which is in a .NET MVC4 Controller Action:
[HttpPost]
public ActionResult NewTransaction(string hash)
{
        var paymentSecret = new BitcoinSecret("//Private Key");
        // Example hash is "45e114a7f2c6122c9c1dabbd4df187e66545c17ca0bd28de732499dbee476811"
        var message = hash;
        var bytes = Encoding.UTF8.GetBytes(message);
        var blockr = new BlockrTransactionRepository();
        var fundingTransaction = blockr.Get("60db94bfb43dd0d98ba7fdfbbg4f29a850f7s5ea7d79a32c4r954096f2945b04");
        var payment = new Transaction();

        payment.Inputs.Add(new TxIn()
        {
            PrevOut = new OutPoint(fundingTransaction.GetHash(), 1)
        });

        payment.Outputs.Add(new TxOut()
        {
            Value = Money.Zero,
            ScriptPubKey = TxNullDataTemplate.Instance.GenerateScriptPubKey(bytes)
        });

        payment.Inputs[0].ScriptSig = paymentSecret.ScriptPubKey;
        payment.Sign(paymentSecret, false);

        using (var node = Node.Connect(Network.Main, "67.221.193.55", new NodeConnectionParameters()
        {
            IsTrusted = true,
            IsRelay = false
        }))
        {
            // Always fails on the handshake
            node.VersionHandshake();
            node.SendMessage(new InvPayload(InventoryType.MSG_TX, payment.GetHash()));
            node.SendMessage(new TxPayload(payment));
            Thread.Sleep(500);
        }
        return View("Index");
}

EDIT
I tried to actually use the TransactionBuilder, but still came up with the same error. This time I am actually setting the fee amount. I am also using a different node and specifying the port. Here is the attempt:
var paymentSecret = new BitcoinSecret("//Private Key");
// Example hash is "45e114a7f2c6122c9c1dabbd4df187e66545c17ca0bd28de732499dbee476811"
var message = hash;
var bytes = Encoding.UTF8.GetBytes(message);

var funding = new Transaction()
{
    Outputs =
    {
        new TxOut("0.01", paymentSecret.GetAddress())
    }
};

var coins = funding
                .Outputs
                .Select((o, i) => new Coin(new OutPoint(funding.GetHash(), i), o))
                .ToArray();

var txBuilder = new TransactionBuilder();
var tx = txBuilder
            .AddCoins(coins)
            .AddKeys(paymentSecret.PrivateKey)
            .Send(TxNullDataTemplate.Instance.GenerateScriptPubKey(bytes), Money.Zero)
            .SendFees("0.00001")
            .SetChange(paymentSecret.PubKey)
            .BuildTransaction(true);

txBuilder.Verify(tx);

using (var node = Node.Connect(Network.Main, "67.221.193.55:8333", new NodeConnectionParameters()
{
    IsTrusted = true,
    IsRelay = false
}))
{
    node.VersionHandshake();
    node.SendMessage(new InvPayload(InventoryType.MSG_TX, tx.GetHash()));
    node.SendMessage(new TxPayload(tx));
    Thread.Sleep(500);
 }

Could anyone help out. There is a lack of documentation specifying how to conduct an OP_RETURN transaction. Thanks.

Based on the reason you posted, it looks like the remote node is timing out. Is this connected to a bitcoin node on your local network, or one over the internet?

One on the Internet. It is timing out...but I've tried a number of reliable nodes with open ports with the same result. That leads me to believe I am not creating the transaction correctly.

I think the problem is that there is only OP_RETURN, I remember seeing in the Bitcoin code that only OP_RETURN without anything else is forbidden.
Except that, your code looks like what is in my book
https://blockchainprogramming.azurewebsites.net/ so I'm almost sure it is the problem.
EDIT : You are crashing during Handshake, can you check Node.DisconnectReason ?

OP_RETURN without a push is okay. See the tests: https://github.com/bitcoin/bitcoin/blob/9fa54a1b0c1ae1b12c292d5cb3158c58c975eb24/src/test/transaction_tests.cpp#L394 Of course, you can disable OP_RETURN standardness entirely by passing datacarrier=0 in bitcoin's config file.

I just checked Node.DisconnectReason. The Reason is Unexpected exception while connecting to socket and the exception is Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

I think your problem is more simpler : your node does not accept new connection. It can happen if there is already too much for it and you are not whitelisted.

@NickODell, yes but a OP_RETURN without any other TxOut is not ok. But he crashes before sending the transaction, so it should not be the problem.

@NicolasDorier I think that's okay too. See how the test has only one item in vout?

@NicolasDorier I've been using bitnodes.21.co to ensure that the node is accepting connections. They have a feature that allows you to type in an IP and test.

@cfly24 if you can't handshake with the node, then it means the node has a problem, try another one.
I tried to find back in bitcoin code where having only op_return txout made the transaction rejected, but I don't find it anymore. I may have dreamed it. However this is not your problem since you crash at the handshake.

The tool on bitnodes tells me that the nodes I am using are accepting incoming connections. I may just switch over to node.js and use the chain api

Node accepting connections is different from node accepting handshake.
So either use Node.Connect(Network) so NBitcoin try to discover a node for you (can take time), or host your own node. If both are out of question, then third party api is fine.

authors: سعيد بن سعيد سعيد حاتم مغلس


text:
Probabilty of a Race Attack in time t with hashing power q
I read the original Satoshi's paper on bitcoin as well as Rosenfeld's paper on "Analysis of hashrate-based double-spending". However, they don't answer my question, which is as follows.
Let's assume attacker has q hash power (less or more than 50%) and that the merchant is waiting k confirmations (e.g. 6). What is the probability that after time t (e.g. 12 hours), the attacker will produce longer chain in order to double-spend money?
I have seen formulas to calculate the probability, that the attacker will eventually produce the chain, but what I am looking for is, what happens if the attacker is constrainted by time t. I know that the attacker has 100% chance on eventually getting the longer chain, but I also know that when the hashing power q is around 50%, it would take a lot of time and you would normally need around 60-70% of hashing power.

The attacker is only guaranteed to eventually get the longer chain when they have more than 50% of hashpower.

@Nick Yes, I know that, but my question is: If the attacker has q hashing power and transaction requires 6 confirmation, then what is the probability, that he will succeed with the attack if he has some time t to perform attack. Let's say he has only control of q hashing power for t time. I think this can be seen as Gambler's Ruin, but trying to calculate the probability of getting x coins with an unfair coin of prob. q

So there are two ways to launch this attack.

(stupid way) get 6 confirmations on a transaction, the go back to the block before the transaction and mine 6 blocks in a private chain before catching up to the mainline and eventually beating it. I would describe this as a race between main chain and private chain where the main chain has a 6-block lead.
(smart way) immediately after the transaction is in the mempool of the main chain, start a private chain with the double spend tx and keep the chain private until there are 6 confirmations on the main chain and release the longer chain into the world to win. I would describe this as a race between the main chain and private chain where they start from the same place.

I think you're talking about doing (1) where (2) is the more likely to succeed attack. With (1), yes, this will take a long time since you have 6 more blocks to catch up. With (2), you're likely to beat (1) soon after however many confirmations. Since the length of the chain is determined by how much proof-of-work is in it, you might be able to win with a shorter chain (!). In any case, calculating the probability of doing so by time T is an interesting problem for (2) but it's at or above your percentage of the hashing power at any length as long as the second method of attack is used.

authors: Евгений Троицкий

authors: امير ادريس كنوء


text:
Can a bad actor omit an unspent address from a pruned chain?
This isn't a problem today, because if I want to run a pruned node then I still have to download the whole chain, but it sure would be nice if I could just download a pruned chain instead and validate it.
The attack I'm thinking of would be that I download a pruned chain, but the person I got it from omitted an unspent address from a thousand blocks back. I'd have no way of knowing.
This means that the full chain will always have to be downloaded and pruned manually. Right?
edit: I think I figured it out. All the unspent addresses on a pruned chain should add up to all the bitcoin in circulation, which is known based on how many blocks there are. So you could tell right away if someone evil omitted an unspent address.. Turns out that doesn't help

This is precisely why Bitcoin Core does not support pruning in this manner. However this does not always need to be the case. There are people working on things like UTXO set syncing where each block commits to the UTXO set as of that block. You can then use that to be sure that you have downloaded the proper blockchain.

Does this mean that each block would have a hash of all the current unspent addresses? Because I think that would solve it.

Not unspent addresses (those don't exist technically). Rather all of the unspent outputs.

Cool, yep I'm convinced that'd solve it. A pruned node would immediately see that they're compromised


text:
How to import private key on testnet and verify balance of wallet?
I have a python library to create wallets and play around with private key generation and stuff like that.
But i can't find any service / wallet - preferably online - where i could import my generated testnet-private-key and check the balance...
I can get coins thru Testnet Faucet and see the balance of an address on testnet via Blockcypher but where can i test importing private keys on the testnet?
EDIT: I don't really want to download the whole blockchain so some online service would really be great!

You shouldn't be importing private keys into any service to check balances. You should calculate the address locally, and then query explorer APIs for the balance.

i rephrased my question here: https://bitcoin.stackexchange.com/questions/76398/how-to-recover-wallet-by-importing-private-key-on-testnet any chance you could answer me there?

I wrote this python library since pybitcointools is no longer supported. You can check testnet balances like this (it pulls data from blockchain.info)
import os
os.environ['CRYPTOTOOLS_NETWORK'] = 'test'

from btctools import Address

address = Address('n2NGrooSecJaiD6ssp4YqFoj9eZ7GrCJ66')

>>> address.balance()
0.55

i rephrased my question here: https://bitcoin.stackexchange.com/questions/76398/how-to-recover-wallet-by-importing-private-key-on-testnet any chance you could answer me there?


text:
bitcoin testnet is mining about 50 blocks per minute right now - why?
The bitcoin test network is mining about 50 blocks every minute for the last several hours. What is going on?
You can see here: https://www.blocktrail.com/tBTC

why?

Because someone set his mining software to testnet. Sorry, this answer is useless, but there is no better answer for this question :) I doubt that the owner of hash power would show his reasons. I do not want to speculate about testing new mining hardware by developers.

There is an adjustment for the testnet when a block takes 20 minutes or longer to mine, it will adjust the difficulty down to 1. This was caused presumably because of the difference between blocktimes of 1356765 and 1356766 because block 1356767 was reset to 1.
Every 2016 blocks, the difficulty is adjusted, but it can only be increased by a factor of 4 each time.
pow.cpp as of version 0.16.2
// Special difficulty rule for testnet:
// If the new block's timestamp is more than 2* 10 minutes
// then allow mining of a min-difficulty block.
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*2)
    return nProofOfWorkLimit;

Bitcoin's difficulty adjusts only every 2016 blocks (though the calculation is done on the previous 2015 blocks, due to an off-by-one error), and there is a maximum limit to the degree of the adjustment. This means that when the hash rate spikes—as it does when someone points a whole rig to the testnet as @amaclin stated—it can take a while until the difficulty adjusts to the point where the block interval reaches 10 minutes again.


text:
What is the best way to create a wallet with a blank keypool then add keys to it?
The scenario is this:
User has a cold storage wallet and will import their cold storage xpub into Bitcoin Core using getdescriptorinfo and importmulti. User wants to only use the keys associated with the imported xpub as a watch-only wallet and wants to exclude all existing keys in the wallet so as to avoid getting an address not associated with their xpub when calling getnewaddress or getrawchangeaddress.
Would the best way to go about this be to create a blank wallet first with:
createwallet "Cold Storage", disable_private_keys: true, blank: true?
Or is there a simpler way to specify which addresses are generated when calling getnewaddress?

Yes, you will want to create a new wallet and specify true for disable_private_keys. It is not necessary to specify blank as disable_private_keys will already ensure that no private keys will be generated or imported and as such, the newly created wallet will be blank anyways.
You can then import xpubs, public keys, and addresses into Bitcoin Core using importmulti. By setting "keypool":true for every public key, the keys will be added to Bitcoin Core's keypool and allow you to use getnewaddress to get addresses. Additionally, for change keys, specifying "internal":true will mark change keys as change and allow you to use getrawchangeaddress, fundrawtransaction, and walletcreatefundedpsbt more easily.
However, be careful when importing an xpub that you use the correct derivation paths. If the child keys that you will eventually be using are derived using hardened derivation, you cannot import an xpub as hardened child keys can only be derived from the master private key. In that case, you will have to import each key by itself, which can also be done using importmulti.

User has a cold storage wallet. User wants to import their xpub into Bitcoin Core and only use the keys associated with the imported xpub as a watch-only wallet.

You must pay attention about the xpub you are talking about and how bitcore core handle HD wallet.
If you already got an xpub, it means it has been generated and derivated from a mnemonic(most likely seed phrase BIP39) with a specific path (BIP44 for xpub -> legacy, BIP49 for ypub -> segwit compatible p2sh(p2wpkh)).
If you restore an xpub which follows BIP44 in electrum for instance no worries. However you simply can't do it in bitcoin core as their derivation path are specific to BIP32 if I'm correct (or their own choice see list) and not BIP44. It means if you got btcs within the xpub following BIP44 you will not find them in bitcoin core and if you use bitcore core new address from your xpub and import it to another wallet you probably won't detect your btc.
Also note that when talking about extended public key for export/import, by convention it's about an extended public keys after harden derivation.
Regarding your initial question, I suggestion to play around rpc and read its commands as you can definitively do it, but stay aware about wallet interoperability...

I understand how to import a BIP84 or BIP44 xpub and derive the keys correctly, my question is how to properly clear the wallet so the keypool does not clash with my imported keys or at least ensure I derive the Cold Storage address on demand. So that when I call getnewaddress I will be guaranteed to get one of my cold storage addresses. Its a lot to experiment with and I am building an app so want to make sure I do it 100% correctly. I will edit the original question to clarify.

This is not an answer to the question; OP asks about importmulti which can (albeit in a roundabout way) import any kind of derivation.

Was not aim to solve OP's question, just a little "heads-up" about wallet interoperability.. perhaps I should have simply avoid this ^^


text:
importmulti with BIP84 derivation always fails
I have been trying to test importmulti with BIP84 derivation like so:
bitcoin-cli -rpcwallet=BIP84Test importmulti '[{ "desc": "wpkh([18734cbe/84'/0'/0']xpub6AC5B4KkrtMkXmzUWAiVVYWvhzwMJDX46ZJhm2tusm7SPc2KjeSqwEjLTaB8vAo7ev3zUFbGdWcX3EMy1ZQ9JxDgpc1pzBGLVpftq84naq5/0/*)#shfp59jm", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false, "rescan": false }]'

But I always get an error:
-bash: syntax error near unexpected token `)'

I have tried replacing [18734cbe/84'/0'/0'] with [18734cbe/84h/0h/0h]
and [18734cbe/84\'/0\'/0\']
But it all returns errors. Is there anything obvious I am doing wrong?
I get the descriptor from getdescriptorinfo
EDIT:
Here is the fix which is working:
First get the descriptor using getdescriptorinfo then:
var descriptor = "\"\(result["descriptor"] as! String)\""

                descriptor = descriptor.replacingOccurrences(of: "4'", with: "4'\"'\"'")
                descriptor = descriptor.replacingOccurrences(of: "0'", with: "0'\"'\"'")

bitcoin-cli -rpcwallet=NewTest importmulti '[{ "desc": "wpkh([18734cbe/84'"'"'/0'"'"'/0'"'"']xpub6AC5B4KkrtMkXmzUWAiVVYWvhzwMJDX46ZJhm2tusm7SPc2KjeSqwEjLTaB8vAo7ev3zUFbGdWcX3EMy1ZQ9JxDgpc1pzBGLVpftq84naq5/0/*)#jun2ynxt", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false }]' '{"rescan": false}'

result = (
        {
        success = 1;
    }
)

Very hacky but it works :)

The issue is that your hardened paths use the single quote notation which breaks the single quoting that surrounds the entire import command. You will need to escape those properly, and \' is not the way to do that. Instead, for every single quote within your import command, you need to do '"'"' - an explanation for why can be found here.
Alternatively, you can change those single quotes to h, but once you do so, you will need to recompute the descriptor checksum. But iff you give such a descriptor to getdescriptorinfo it will give you back the descriptor with single quotes (there is a pull request open to fix this) so you will need to use an external checksum tool to do this. I have a python script which can do this.
Running your descriptor with h instead of ' through that script, I get:
wpkh([18734cbe/84h/0h/0h]xpub6AC5B4KkrtMkXmzUWAiVVYWvhzwMJDX46ZJhm2tusm7SPc2KjeSqwEjLTaB8vAo7ev3zUFbGdWcX3EMy1ZQ9JxDgpc1pzBGLVpftq84naq5/0/*)#rxk7wl9c

amazing, thank you yet again. Editing OP to show working code for anyone else who is trying


text:
How to properly use importmulti with coldcard wallet BIP84 xpub?
I have seen the HWI scripts but I am trying to do this while keeping my Coldcard airgapped.
First I create a wallet in bitcoin core with private keys disabled.
I dump the wallet summary onto the coldcard SD card and it outputs:
# Coldcard Wallet Summary File

## Wallet operates on blockchain: Bitcoin Testnet

For BIP44, this is coin_type '1', and internally we use symbol XTN for this blockchain.

## Top-level, 'master' extended public key ('m/'):

tpubD6NzVbkrYhZ4Y7XQkmZe9fchT8GBdsx9MSjEbnTPAhC1FPUHJLD9dcEudPWUayLGy1MtVqu73a2QfaUv3YB54yUNesAc8dShcUTUNmMhopY

Derived public keys, as may be needed for different systems:

## For Bitcoin Core: m/{account}'/{change}'/{idx}'

m => tpubD6NzVbkrYhZ4Y7XQkmZe9fchT8GBdsx9MSjEbnTPAhC1FPUHJLD9dcEudPWUayLGy1MtVqu73a2QfaUv3YB54yUNesAc8dShcUTUNmMhopY

... first 5 receive addresses (account=0, change=0):

m/0'/0'/0' => mwokgDX6HQREsFgevxZwKDxmVfDjEqwPuC
m/0'/0'/1' => mwGmYgnd3MDjaTXfp5dgq5YxNtGjfRyTuT
m/0'/0'/2' => mntHLuyhXr6QsVsWstRs3XFHaMXD8AKuLo
m/0'/0'/3' => msU7yGFgbqTJF9n55jYB8e3Hxh4hi7vhhF
m/0'/0'/4' => mjdKAoMcyieEwcscdvrnKzqu4r6bnfQMj1

## For Bitcoin Core (Segregated Witness, P2PKH): m/{account}'/{change}'/{idx}'

m => tpubD6NzVbkrYhZ4Y7XQkmZe9fchT8GBdsx9MSjEbnTPAhC1FPUHJLD9dcEudPWUayLGy1MtVqu73a2QfaUv3YB54yUNesAc8dShcUTUNmMhopY
# SLIP-132 style
m => vpub5SLqN2bLY4WeZixKds1JXa6Kn4sdmFU5yb6VgScU4mgMPuB7io2wF3FoLwWX4f5CMpbNPKC7b9VGCpmBDHVob4esrb2THH9VV4jmqZ4QqHz

... first 5 receive addresses (account=0, change=0):

m/0'/0'/0' => tb1qk2hk9sdh0akzyc99nx65a2erpuftcek3v4mret
m/0'/0'/1' => tb1q4nfn0gme6yr9fezwlrdzdycfpztswal0j4l38m
m/0'/0'/2' => tb1q2rgcg659h4fte2c6dzljzskyjz5qfftrfwcyv7
m/0'/0'/3' => tb1qsvv9dv4g7uepe5pk0tf3cp7hdgnmtx5hp626ap
m/0'/0'/4' => tb1q952xefka88ep3s8htxgnw0n60a4spqwfppm5mu

## For Electrum (not BIP44): m/{change}/{idx}

m => tpubD6NzVbkrYhZ4Y7XQkmZe9fchT8GBdsx9MSjEbnTPAhC1FPUHJLD9dcEudPWUayLGy1MtVqu73a2QfaUv3YB54yUNesAc8dShcUTUNmMhopY

... first 5 receive addresses (account=0, change=0):

m/0/0 => mu7NuiLq1PsK7ncvE5cN3YPwU89wCjz4fC
m/0/1 => mvSCNC4w9wBRksZwQsLPL4pyNMbHB8rFKy
m/0/2 => mooEuT4TzKte4yvNxk4T7Du9K9vG1ZfjyK
m/0/3 => mpuSJdR1W3WLEH1FN3KN3Mxye9dBnnJYd6
m/0/4 => miwaFWAkjmAggdFGix4SGiSxaq4zzue78B

## For BIP44 / Electrum: m/44'/1'/{account}'/{change}/{idx}

m/44'/1' => tpubDALcajyQQtb5HRLZ8jAJhVhxbGVY7vSJWfxuYUknNMQDZzjQdWtge5GDNnqw5jB8wCDuDXp1tJQkFbZyE1YmYawBrJZiHeRWfXr7KBQoxUM

... first 5 receive addresses (account=0, change=0):

m/44'/1'/0'/0/0 => n2sEggcZ9vztixvwaEtf9aJPXTze4qcyEK
m/44'/1'/0'/0/1 => mix1rdoLEzR1n7pmfkRLJRL2eCVhoL9xD6
m/44'/1'/0'/0/2 => mwAy5FLgdKzGnjTwUbkpd7Fp97cRKNjY56
m/44'/1'/0'/0/3 => mi5RvZpkR9yKtxLiVwWqYXiHaYzjskSKgF
m/44'/1'/0'/0/4 => mujhjLQ9cpyqNjbv6NAPTUA6HWjBP64HZv

## For BIP49 (P2WPKH-nested-in-P2SH): m/49'/1'/{account}'/{change}/{idx}

m/49'/1' => tpubDBJSfnStqiS6NpVyZjTGpR27FQQG5x6nAKwycydndiNUcuexGYbc5aW5KE9bAKmTWRWQF6ihZySoZHRLZk3hCFGfjS3nUNgkrS29K3Aa635
# SLIP-132 style
m/49'/1' => upub5CS2EYcTgPrCZ8jmcU7JzEQEQNsGGhdDsMo1vEtz9nUwiKYZSMFq4wrq1aC3e6rTVbd5P6R9etZ7DF631nxQv6ma4pDD37a4TJEoPMWrETv

... first 5 receive addresses (account=0, change=0):

m/49'/1'/0'/0/0 => 2NFLZEZVQizq4j1RbPmrM4PDCBVBJT8yz8g
m/49'/1'/0'/0/1 => 2MtnK8YM3trNgW1SGKnHVLxUGQinHJ9gzJN
m/49'/1'/0'/0/2 => 2Muj9cwcCCm6r7qpLxUHe1mRz4D1ikmuGSu
m/49'/1'/0'/0/3 => 2NAwepU6eSdb1c6nnV13SJAqSJEYjbUeNGB
m/49'/1'/0'/0/4 => 2N7bVgw1d1jmipnFL95droVt5JgKvfw9cRr

## For BIP84 (Native Segwit P2PKH): m/84'/1'/{account}'/{change}/{idx}

m/84'/1' => tpubDAZhhJ9SaAKCt2gngU8aA2babxVAM93oBgo2wGknMUDmtLrzvLnynFuAYo4eME3MqWpcTM3DpGL9J45nQw7CA7VroAY8e7v9Zo6r7mddUMS
# SLIP-132 style
m/84'/1' => vpub5WXYZiyvZXGnue7hZZaEXw5Cvu6cUWZjoqAJ1vusFYi82rZqLocmPgv4GM4gpunHEL46LpLEMqnzqJN3agRvgCgMztPynmcwSPP9aYGfxLs

... first 5 receive addresses (account=0, change=0):

m/84'/1'/0'/0/0 => tb1qtymulkjmx26pvq6n45sly2gmttwc4g5vtgzxez
m/84'/1'/0'/0/1 => tb1q4gcq8et9qvjy3cffzqmhr2qtchhvdy9x6v08cd
m/84'/1'/0'/0/2 => tb1qnmw70uefcns626xu4umftmqx8n7wjusxej7k32
m/84'/1'/0'/0/3 => tb1qzdtj4cn6kj3lt3uha9my2skh0a99e0u59tw45r
m/84'/1'/0'/0/4 => tb1q27ysu4ut4v3wv4xsq55wvrlyn7n4xqjfsslz4h

I want to import the BIP84 tpub so I use the BIP84 tpub as provided above.
In bitcoin core I call:
bitcoin-cli getdescriptorinfo "wpkh([18734cbe/84h/1h/0h]tpubDAZhhJ9SaAKCt2gngU8aA2babxVAM93oBgo2wGknMUDmtLrzvLnynFuAYo4eME3MqWpcTM3DpGL9J45nQw7CA7VroAY8e7v9Zo6r7mddUMS
/0/*)"

responseString = {

  "descriptor": "wpkh([18734cbe/84'/1'/0']tpubDAZhhJ9SaAKCt2gngU8aA2babxVAM93oBgo2wGknMUDmtLrzvLnynFuAYo4eME3MqWpcTM3DpGL9J45nQw7CA7VroAY8e7v9Zo6r7mddUMS/0/*)#4c563hxu",
  "isrange": true,
  "issolvable": true,
  "hasprivatekeys": false

}

bitcoin-cli -rpcwallet=BIP84 importmulti '[{ "desc": "wpkh([18734cbe/84'"'"'/1'"'"'/0'"'"']tpubDAZhhJ9SaAKCt2gngU8aA2babxVAM93oBgo2wGknMUDmtLrzvLnynFuAYo4eME3MqWpcTM3DpGL9J45nQw7CA7VroAY8e7v9Zo6r7mddUMS/0/*)#4c563hxu", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false }]' '{"rescan": false}'

result = (
        {
        success = 1;
    }
)

I have tried many combinations but this most reflects the instructions I found here https://github.com/bitcoin-core/HWI/blob/master/docs/bitcoin-core-usage.md
When I call:
bitcoin-cli -rpcwallet=BIP84 getnewaddress "*", "bech32"

responseString = tb1qf3fvy6s4a6y659cmrp829z9g8743ne7zynrzdu

Which is not a correct address. Can anyone point out what I am doing wrong here?
EDIT:
bitcoin-cli -rpcwallet=BIP84 getaddressinfo "tb1qf3fvy6s4a6y659cmrp829z9g8743ne7zynrzdu"
{
  "address": "tb1qf3fvy6s4a6y659cmrp829z9g8743ne7zynrzdu",
  "scriptPubKey": "00144c52c26a15ee89aa171b184ea288a83fab19e7c2",
  "ismine": false,
  "solvable": true,
  "desc": "wpkh([18734cbe/84'/1'/0'/0/0]02e36718f3ef012d322e335dc85e8ef9fcd5b859b719800a111ac46ea67cf34b1f)#rj2ve2jp",
  "iswatchonly": true,
  "isscript": false,
  "iswitness": true,
  "witness_version": 0,
  "witness_program": "4c52c26a15ee89aa171b184ea288a83fab19e7c2",
  "pubkey": "02e36718f3ef012d322e335dc85e8ef9fcd5b859b719800a111ac46ea67cf34b1f",
  "label": "*,",
  "ischange": false,
  "timestamp": 0,
  "hdkeypath": "m/84'/1'/0'/0/0",
  "hdseedid": "0000000000000000000000000000000000000000",
  "hdmasterfingerprint": "18734cbe",
  "labels": [
    {
      "name": "*,",
      "purpose": "receive"
    }
  ]
}

I was using an outdated firmware for coldcard wallet so that may be the issue, will update it try again and revert.

I don't see anything obviously wrong with what you've done. I am very curious about the output of getaddressinfo tb1qf3fvy6s4a6y659cmrp829z9g8743ne7zynrzdu. What's the descriptor for that key? It should be m/84'/1'/0'/0/0 but perhaps it isn't?

Have edited OP, also have gotten useful info from Coldcard wallet support (you?), will have another go and update the post later.

Updating the ColdCard to the latest (unreleased) firmware shows the xpub that is compatible with my above code and works flawlessly with the above example.
The same ColdCard with the new dump summary outputs:
# Coldcard Wallet Summary File
## For wallet with master key fingerprint: 18734CBE

Wallet operates on blockchain: Bitcoin Testnet

For BIP44, this is coin_type '1', and internally we use
symbol XTN for this blockchain.

## IMPORTANT WARNING

Do **not** deposit to any address in this file unless you have a working
wallet system that is ready to handle the funds at that address!

## Top-level, 'master' extended public key ('m/'):

tpubD6NzVbkrYhZ4Y7XQkmZe9fchT8GBdsx9MSjEbnTPAhC1FPUHJLD9dcEudPWUayLGy1MtVqu73a2QfaUv3YB54yUNesAc8dShcUTUNmMhopY

What follows are derived public keys and payment addresses, as may
be needed for different systems.

## For Bitcoin Core: m/{account}'/{change}'/{idx}'

First 5 receive addresses (account=0, change=0):

m/0'/0'/0' => tpubDCATeo6yFBpS7m1szppzMD7zkNcgECxMe8LBxePPEYoPzFmZGQp2pismcwtB4va9pXoGVMjRXGtqQHFKg1adNSy6GXGEnSYtdaeSww1Dkdg
m/0'/0'/0' => mwokgDX6HQREsFgevxZwKDxmVfDjEqwPuC

m/0'/0'/1' => tpubDCATeo6yFBpSAe4W2y8LkYvvzzQrJgyQS95Uys623N17e4Rnc33kkbv2LPkB45aWAUkdttapuEjQRK5pRLD6B1Z8dRRrBdwFBTAQGz5HMDe
m/0'/0'/1' => mwGmYgnd3MDjaTXfp5dgq5YxNtGjfRyTuT

m/0'/0'/2' => tpubDCATeo6yFBpSDMgwGGC9vQkadkkFFDgsSP67BrFpZ543PMgaLuof9EYmdvAxLeCyuG8B6XP6q1yywfaFGofdnmMTN9LooLzSeb93dH3tTQE
m/0'/0'/2' => mntHLuyhXr6QsVsWstRs3XFHaMXD8AKuLo

m/0'/0'/3' => tpubDCATeo6yFBpSGritemWBfB6SGxjzKXZdk9SKW2Kwpj4Qm6efgQjEV1nmj16ZAuxguYJWCvSeibnGpeSaNMb44MZnCJ9LajcHuSCis7Ect3n
m/0'/0'/3' => msU7yGFgbqTJF9n55jYB8e3Hxh4hi7vhhF

m/0'/0'/4' => tpubDCATeo6yFBpSJGFBLgD7UAmveDdpnCsjT6Dy1YZD5XsbUNyzc4aczhTF9956SZN6mREKDmeQFnkTtHfRTAvh6NQZoZ6oHMickZBu9GXkGRW
m/0'/0'/4' => mjdKAoMcyieEwcscdvrnKzqu4r6bnfQMj1

## For Bitcoin Core (Segregated Witness, P2PKH): m/{account}'/{change}'/{idx}'

First 5 receive addresses (account=0, change=0):

m/0'/0'/0' => tpubDCATeo6yFBpS7m1szppzMD7zkNcgECxMe8LBxePPEYoPzFmZGQp2pismcwtB4va9pXoGVMjRXGtqQHFKg1adNSy6GXGEnSYtdaeSww1Dkdg
m/0'/0'/0' => tb1qk2hk9sdh0akzyc99nx65a2erpuftcek3v4mret

m/0'/0'/1' => tpubDCATeo6yFBpSAe4W2y8LkYvvzzQrJgyQS95Uys623N17e4Rnc33kkbv2LPkB45aWAUkdttapuEjQRK5pRLD6B1Z8dRRrBdwFBTAQGz5HMDe
m/0'/0'/1' => tb1q4nfn0gme6yr9fezwlrdzdycfpztswal0j4l38m

m/0'/0'/2' => tpubDCATeo6yFBpSDMgwGGC9vQkadkkFFDgsSP67BrFpZ543PMgaLuof9EYmdvAxLeCyuG8B6XP6q1yywfaFGofdnmMTN9LooLzSeb93dH3tTQE
m/0'/0'/2' => tb1q2rgcg659h4fte2c6dzljzskyjz5qfftrfwcyv7

m/0'/0'/3' => tpubDCATeo6yFBpSGritemWBfB6SGxjzKXZdk9SKW2Kwpj4Qm6efgQjEV1nmj16ZAuxguYJWCvSeibnGpeSaNMb44MZnCJ9LajcHuSCis7Ect3n
m/0'/0'/3' => tb1qsvv9dv4g7uepe5pk0tf3cp7hdgnmtx5hp626ap

m/0'/0'/4' => tpubDCATeo6yFBpSJGFBLgD7UAmveDdpnCsjT6Dy1YZD5XsbUNyzc4aczhTF9956SZN6mREKDmeQFnkTtHfRTAvh6NQZoZ6oHMickZBu9GXkGRW
m/0'/0'/4' => tb1q952xefka88ep3s8htxgnw0n60a4spqwfppm5mu

## For Electrum (not BIP44): m/{change}/{idx}

First 5 receive addresses (account=0, change=0):

m => tpubD6NzVbkrYhZ4Y7XQkmZe9fchT8GBdsx9MSjEbnTPAhC1FPUHJLD9dcEudPWUayLGy1MtVqu73a2QfaUv3YB54yUNesAc8dShcUTUNmMhopY
m/0/0 => mu7NuiLq1PsK7ncvE5cN3YPwU89wCjz4fC
m/0/1 => mvSCNC4w9wBRksZwQsLPL4pyNMbHB8rFKy
m/0/2 => mooEuT4TzKte4yvNxk4T7Du9K9vG1ZfjyK
m/0/3 => mpuSJdR1W3WLEH1FN3KN3Mxye9dBnnJYd6
m/0/4 => miwaFWAkjmAggdFGix4SGiSxaq4zzue78B

## For BIP44 / Electrum: m/44'/1'/{account}'/{change}/{idx}

First 5 receive addresses (account=0, change=0):

m/44'/1'/0' => tpubDDZWqt7mxh5QsvFMmPtJcx1FGsXc5LXTaBFNfq9h8jF7UHhi4UWuVJLBT6qqGygoDzj3j1628QyzUwkK19FDGhKam2UXBLxNebBWNJVxn9z
m/44'/1'/0'/0/0 => n2sEggcZ9vztixvwaEtf9aJPXTze4qcyEK
m/44'/1'/0'/0/1 => mix1rdoLEzR1n7pmfkRLJRL2eCVhoL9xD6
m/44'/1'/0'/0/2 => mwAy5FLgdKzGnjTwUbkpd7Fp97cRKNjY56
m/44'/1'/0'/0/3 => mi5RvZpkR9yKtxLiVwWqYXiHaYzjskSKgF
m/44'/1'/0'/0/4 => mujhjLQ9cpyqNjbv6NAPTUA6HWjBP64HZv

## For BIP49 (P2WPKH-nested-in-P2SH): m/49'/1'/{account}'/{change}/{idx}

First 5 receive addresses (account=0, change=0):

m/49'/1'/0' => tpubDCKpfULue5a7s9eEYJR48AGYxTiQt3gFqJS7VLmYxFjEiw7zDGxYkxtFJsyJd6i5QPfDGvDF9YTZWXqXq47PmGmEf8FQedYZRtp6oJdR5Cu
m/49'/1'/0' => upub5DTQEEWUUkzE3Tt2b356Hyeg7SBR4oChYLH9nc2kUKqhpM1bP5cmkLF11E1m6so5PZmtQuuhETZsAVWEH727V8G8zWQqDNRs2m2ksa22a9V   ##SLIP-132##
m/49'/1'/0'/0/0 => 2NFLZEZVQizq4j1RbPmrM4PDCBVBJT8yz8g
m/49'/1'/0'/0/1 => 2MtnK8YM3trNgW1SGKnHVLxUGQinHJ9gzJN
m/49'/1'/0'/0/2 => 2Muj9cwcCCm6r7qpLxUHe1mRz4D1ikmuGSu
m/49'/1'/0'/0/3 => 2NAwepU6eSdb1c6nnV13SJAqSJEYjbUeNGB
m/49'/1'/0'/0/4 => 2N7bVgw1d1jmipnFL95droVt5JgKvfw9cRr

## For BIP84 (Native Segwit P2PKH): m/84'/1'/{account}'/{change}/{idx}

First 5 receive addresses (account=0, change=0):

m/84'/1'/0' => tpubDCQUid7gmQWq7GLdF6D7fN8RFvEocAUUSxE1Sy74aqtCBgZ8pbPCGSNKpA8nGR8HwN9agAHS4kgngs2Ey9VVFgPKz8cDvBHHZ9sCqAtUVQK
m/84'/1'/0' => vpub5YNKb3xAkmUR8smY8Ben3Gc3arrFjXzR56bGXdG9UvNYLCFyF4CyssPDXi8pk6sDLBP4ZdaScL9eE7JW8tpDmmZqBrU54pz5Rk9WJ11aUMc   ##SLIP-132##
m/84'/1'/0'/0/0 => tb1qtymulkjmx26pvq6n45sly2gmttwc4g5vtgzxez
m/84'/1'/0'/0/1 => tb1q4gcq8et9qvjy3cffzqmhr2qtchhvdy9x6v08cd
m/84'/1'/0'/0/2 => tb1qnmw70uefcns626xu4umftmqx8n7wjusxej7k32
m/84'/1'/0'/0/3 => tb1qzdtj4cn6kj3lt3uha9my2skh0a99e0u59tw45r
m/84'/1'/0'/0/4 => tb1q27ysu4ut4v3wv4xsq55wvrlyn7n4xqjfsslz4h

Then in Bitcoin Core using the updated fingerprint and tpub for BIP84:
bitcoin-cli getdescriptorinfo "wpkh([18734CBE/84h/1h/0h]tpubDCQUid7gmQWq7GLdF6D7fN8RFvEocAUUSxE1Sy74aqtCBgZ8pbPCGSNKpA8nGR8HwN9agAHS4kgngs2Ey9VVFgPKz8cDvBHHZ9sCqAtUVQK/0/*)"
responseString = {
  "descriptor": "wpkh([18734cbe/84'/1'/0']tpubDCQUid7gmQWq7GLdF6D7fN8RFvEocAUUSxE1Sy74aqtCBgZ8pbPCGSNKpA8nGR8HwN9agAHS4kgngs2Ey9VVFgPKz8cDvBHHZ9sCqAtUVQK/0/*)#8enle6r3",
  "isrange": true,
  "issolvable": true,
  "hasprivatekeys": false
}

bitcoin-cli -rpcwallet=ColdCardUpdate importmulti '[{ "desc": "wpkh([18734cbe/84'"'"'/1'"'"'/0'"'"']tpubDCQUid7gmQWq7GLdF6D7fN8RFvEocAUUSxE1Sy74aqtCBgZ8pbPCGSNKpA8nGR8HwN9agAHS4kgngs2Ey9VVFgPKz8cDvBHHZ9sCqAtUVQK/0/*)#8enle6r3", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false }]' '{"rescan": false}'
responseString = [
  {
    "success": true
  }

bitcoin-cli -rpcwallet=ColdCardUpdate getnewaddress "", "bech32"

responseString = tb1qtymulkjmx26pvq6n45sly2gmttwc4g5vtgzxez


text:
How to create the data parameter for a PSBT?
I am sure this is a dumb question but if using:
bitcoin-cli walletcreatefundedpsbt "[{\"txid\":\"myid\",\"vout\":0}]" "[{\"data\":\"00010203\"}]"
How do you create the data parameter? Where does it come from?
\"00010203\"
Edit:
I should have read the BIP first, it looks like it is an unsigned tx. So in order to create a PSBT you need to first create an unsigned tx? And include the hex as an argument.

A PSBT contains an unsigned transaction that has all of the inputs and output that you want. The other data PSBT allows for are put in around that unsigned transaction.
Here, data just means that the unsigned transaction will have an output that has an OP_RETURN followed by whatever data you want. This directly reflects what createrawtransaction. data is not specific to PSBT nor is it necessary.

Thanks again Andrew, and thanks for your great contributions.

Thanks! it would be useful to specify it a little better in the "help", because now it seems the parameter is mandatory and it is not trivial to find this useful post.