text:
How to spend a multisig descriptor wallet transaction with bitcoin-cli?
I am looking for the correct way to spend multisig outputs with descriptor wallet bitcoin-cli.
In regtest, I successfully created a funding transaction tx1 with the following outputs:
out:0 sh(multi(1,KEY1,KEY2))
out:1 wsh(multi(1,KEY3,KEY4,KEY5))
I used bitcoin-cli -regtest deriveaddresses to get P2SH_ADDRESS and P2WSH_ADDRESS from these descriptors and then
bitcoin-cli -regtest -rpcwallet="$WALLET" createrawtransaction '''
  [
    {
      "txid": "'$prev_tx'",
      "vout": 0
    }
  ]
''' '''
  {
    "'$P2SH_ADDRESS'": 3,
    "'$P2WSH_ADDRESS'": 2,
    "'$CHANGE_ADDRESS'": 18
  }
'''

Then I broadcast and mined this transaction.
Now I want to create a spending transaction, that spends both of these inputs, using
PSBT=$( bitcoin-cli -regtest -named createpsbt inputs='''[
  {
    "txid": "tx1",
    "vout": 0
  },
  {
    "txid": "tx1",
    "vout": 1
  },
]''' outputs='''[
  {
    "'$ADDRESS1'": 1
  },
  {
    "'$ADDRESS2'": 1
  },
  {
    "$CHANGE_ADDRESS": 4
  }
]''')

My main question:

how do I add input information to this PSBT (i.e. redeemScript for inp:0 and witnessScript for inp:1)? What is the modern correct way to get a redeemScript and a witnessScript given output descriptors?

My second question:

say KEY1,KEY3 belong to wallet1, and KEY2,KEY4,KEY5 belong to wallet2. I want to spend out:0 using KEY1 and out:1 using KEY4.
I tried to simply sign with both wallets: bitcoin-cli -regtest -rpcwallet=walletN walletprocesspsbt $PSBT but is it possible to select the specific key (i.e. wallet in this case) between KEY1 and KEY2 to spend the sh(multi(1,KEY1,KEY2)) vout:0, these keys are from the different wallets? And is it even correct to use walletprocesspsbt in this case?

Found an answer to my main question after trial and error:
One needs to first create a watch-only wallet and import descriptors into it, like so:
bitcoin-cli -regtest createwallet "multisig_watch" true true "" false true

bitcoin-cli -regtest -rpcwallet=multisig_watch importdescriptors "[
  {\"desc\":\"$DESCRIPTOR_PREVOUT0\", \"timestamp\":\"now\"},
  {\"desc\":\"$DESCRIPTOR_PREVOUT1\", \"timestamp\":\"now\"}
]"

Then update PSBT with that watch-only wallet:
# Update PSBT with watch-only wallet
PSBT=$(bitcoin-cli -regtest -rpcwallet=multisig_watch walletprocesspsbt "$PSBT")

After that the raw PSBT created with createpsbt will gain the required redeemScript and witnessScript data.
Then, sign as usual with all wallets that contain corresponding private keys for redemption:
for wallet in "${signing_wallets[@]}"; do
  PSBT=$( bitcoin-cli -regtest -rpcwallet=$wallet walletprocesspsbt $(jq -r .psbt <<< $PSBT))
done

I think these multisig operations should be better documented in Bitcoin Core.
What remains unclear is if I have sh(multi(1,KEY1_FROM_WALLET1,KEY2_FROM_WALLET2,KEY3_FROM_WALLET2,...))
if/how I can explicitly choose between KEY2_FROM_WALLET2 and KEY3_FROM_WALLET2?


text:
How do I protect my paper wallet from use by a different human who has used a random generator?
Since millions of people use Bitcoin and Bitcoin Wallets that use their own addresses use several addresses per day, it is obvious that generators can generate the same characters for the Bitcoin address multiple times. So please therefore simply tell me how one would prevent others from accessing or spending the coins that are stored at my paper bitcoin address.

"that is improbable so therefore who cares": This is the entire point! Cryptography never makes anything truly impossible, but it can make it so improbable that you no longer worry about it happening.  You have to understand and accept this before you can go on to understand anything else.

My first Google result for "bitcoin address duplication" is https://bitcoin.stackexchange.com/questions/23268/what-if-duplicate-wallet-addresses-are-created which links to two additional dupes.

The point of ignoring probabilities here makes literally no sense. You could just as sensibly ask about physical money you held simply flying away spontaneously due to random atomic vibrations and quantum physics. Yes, it could happen, no, it wont.

I could also spontaneously combust. Statistically SOMETHING could trigger it (I agree, super unlikely... but still). I don't carry a fire extinguisher with me just in case (and I assume you don't)... it's all about risk management and understanding what "1 in a trillion" (or whatever) really means. I am aware that in the world of bitcoin, it's FAR LESS than 1/trillion btw...

I think that "having a probability greater than 0" is a poor definition of "possible". After all, the probability that I will grow wings and become an airplane tomorrow is greater than 0, but that isn't the sort of thing you'd call possible, is it? So, don't be so sure that it's possible for someone else to end up with the same private key that you ended up with.

try to focus on the question, not the rant. the current ‘question’ is 90% rant.

@Raven: try to edit your question into open–ended wording, and you might make it easier for the community to find a proper answer. Maybe the question should be „how possible is it to duplicate an address randomly“. There are roughly 20 posts on this forum here and in bitcointalk. They explain the math, and people would be more than happy to provide corresponding links. With you wording this is nearly impossible....

"Improbable" is an understatement.
There are 2256 possible keys.  In the entire universe, there are estimated to be "only" 2100 atoms.
So the odds of someone else ending up with the exact same address/key as you is far, far less than the same atom, out of the entire universe, being randomly picked twice.
If you are worried about an address collision, here are things that should be more worrisome:

Gamma ray burst wiping out all life on earth.
Sun unexpectedly going Supernova
Rogue Blackhole swallowing the solar system
An asteroid hitting the earth at the same time as nuclear war breaks out.

On the list of things to worry about, an address collision just does not show up.

You say that "millions of people use Bitcoin and Bitcoin Wallets that use their own addresses use several addresses per day".
  100 Million of people
  100 addresses per day
  365 days / year
* 200 years
-------------
Less than 1 Billion addresses used in the foreseeable future.

1 billion is about 230.
Which means that in 200 years, the chance of a collision is somewhere around 1 in 2256-30 or, 1 in 2226, which is still way more than atoms in the universe.
You're easily safe for at least 200 years.

Slightly less than 2^256 keys, but 2^160 addresses and forgery only requires matching the address. Still infeasible.

How do you protect your paper wallet from mice nibbling on the paper?  As far as probabilities go, I'd be far more concerned with that than random number hits.

Did you account for the birthday paradox in your last section?  I think the real probability of any collision occurring (for anyone, not just you) is 2^96.  We're at least getting down to the number of atoms in the universe.  Or, if we prefer to think in positive terms, the probability of someone having a collision happen in the next 200 years is equivalent to you winning the Powerball lottery 4 times in a row.

Also, studying the Large Bitcoin Collider project might make it seem more of a 'real' problem than one might distil from this answer.

https://motherboard.vice.com/en_us/article/nzpv8m/the-large-bitcoin-collider-is-generating-trillions-of-keys-and-breaking-into-wallets  "the project has generated over 3,000 trillion private keys and ... has found three that contain bitcoin.";   "the brute force strategy they're using poses no threat to anybody's bitcoin."

@abelenky More than 3 (10+) as of the writing of this comment.

Nope, I only see 3.  The rest you see all note they are part of the "Puzzle Transaction", a sequence of addresses that was deliberately created as a puzzle in a non-secure manner, and is meant to be solved.

The generation of private keys is made randomly. Therefore, it is possible for someone to generate the same private key as you did. In your question, you heavily insisted that you did not want an answer on how improbable this is. The answer is : You cannot protect your paper wallet from someone having incredible chance and getting the same number generated as you did.If you do not trust the way private keys are generated, you should take a look at this article.

So – for all those doubting the security of 2^256 collision chances, there’s the number: There is a 1 in over 115 quattuorvigintillion (that’s a 78 digit number) chance of finding a collision. This number is bigger than the number of atoms in the perceivable universe

The idea of ignoring sufficiently small possibilities is fundamental to BitCoin, and if you have a problem with it, then you shouldn't be using BitCoin (or anything else that involves a finite password space). If someone were to simply create a forged transaction from your wallet, put it in a block, and find a hash for that block, being able to do that by random chance would be likelier than picking the same keys as you. Randomly choosing a name and social security number and having it match yours would be likelier. Randomly choosing a credit card number, expiration date, and cvv, and having it match yours would be likelier. You are waaaaaaaaay more likely to lose your BitCoins from your wallet being trampled by a zebra who's been spooked by lightning hitting someone who just won the lottery than from someone randomly choosing the same keys.

If you consider this a "stupid question", it apparently isn't, because Google has literally no results whatsoever about this.

That logic is valid only if it is reasonable to expect Google to have answers to every stupid question.

The Large Bitcoin Collider was already mentioned in a comment, but it is worth mentioning in an answer also.
These are a group of people out there doing this now, going through random BTC private keys looking for wallets with money in them. So far they have found private key for three wallets, worth 0.0079 BTC, 0.0001 BTC and 0.00001 BTC. In addition they've found several keys related to a puzzle transaction, which apparently used intentionally guessable keys.
Their current search speed is 1550 Mkeys/s. If you have a single wallet with a random private key, this means that by average you'll be hit once every 3 · 10³¹ years. So for an individual user, the statistical risk is insignificant. There are 15 millions wallets with money in them, so even the chance of hitting any wallet is just once every 2 · 10²⁴ years. Their hits so far are much higher than this, which suggests not all keys are as random as one would expect. Someone may have even made the addresses intentionally for LBC to find, but no-one knows.
The real risk is in your random generator that you used to generate your private key. A few years back, Debian's OpenSSL package had a very bad random generator bug. This made it trivial to guess all private keys generated with it, yet it took two years until the problem was publicly detected. I would be somewhat wary of using less commonly used or experimental software to generate private keys, a single bug could make the wallet easy to compromise.
But as long as you use a well designed software to generate the key, you should be safe.

What all of url don't realise is that is not impossible for hackers to brute the crap out of private keys, with computer processing increasing rapidly it's definitely not IMPOSSIBLE, to put the record straight, but then again that's vulnerability as being around since computers started to exist.

Yes, it is impossible.

source: Stack Exchange

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

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

sort: votes


text:
Why I can't do a transaction by use sendtoaddress?
It's seems like this question, but it's no clear show. I have followed this step by step, and after finish last step which generate a block to confirm the transaction, I couldn't see my second address have add money (bitcoin). Anyone who encountered such problem?
My bitcoin.conf
[frank@localhost bin]$ cat ~/.bitcoin/bitcoin.conf
rpcpassword=this_is_a_password_for_api_call

Run my bitcoind like
[frank@localhost bin]$ ./bitcoind -regtest -daemon
Bitcoin server starting

Run my bitcoin-cli as
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance
0.00000000

[frank@localhost bin]$ ./bitcoin-cli -regtest generate 101
[
  "7b611f41281c882c7b786c74e01b70e990c102aefb5fc28ee12c1d5b90156fb3",
  "505699b3bcb9faa394cb3533ed970ca48195643e1a034fc8fe64a34e019e12cd",
  "3845286183586d91f3b6a64aa5fb7f741378747b82ed781bc32e2a9d79ac22af",
  "342c881a888de56524368fc04735edfbb23ab1767717df8f9c68218a57b852ee",
....]
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance
50.00000000

You can see what I've done at above, everything so far so good. When I try to do the following thing, I meet some trouble.
[frank@localhost bin]$ ./bitcoin-cli -regtest getnewaddress
2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV

[frank@localhost bin]$ ./bitcoin-cli -regtest sendtoaddress 2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV 10
89d08e5517a8f40cfca50b0323c835056c166255d8430897affa6c1cde797b18

For now, I will list all transactions to you:
[frank@localhost bin]$ ./bitcoin-cli -regtest listunspent 0
[
  {
    "txid": "89d08e5517a8f40cfca50b0323c835056c166255d8430897affa6c1cde797b18",
    "vout": 0,
    "address": "2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV",
    "account": "",
    "redeemScript": "0014b24df37ce7d779a84b06b35517fae3c8229daa3c",
    "scriptPubKey": "a914910f020cef414bcafc49ab1236c82be6367045f287",
    "amount": 10.00000000,
    "confirmations": 0,
    "spendable": true,
    "solvable": true,
    "safe": true
  },
  {
    "txid": "89d08e5517a8f40cfca50b0323c835056c166255d8430897affa6c1cde797b18",
    "vout": 1,
    "address": "2NDjzxeozTK8uZ567tCBvCY9aqCL5wKL4rs",
    "redeemScript": "00143a1c7678f95db28e17c47ab32e9a7e8be5b5150a",
    "scriptPubKey": "a914e0d3b4074fdb1a3defd5ca0e660d3c656b0b054087",
    "amount": 39.99996240,
    "confirmations": 0,
    "spendable": true,
    "solvable": true,
    "safe": true
  }
]

You can see the transaction's confirmations is 0, it's mean no confirmed. so last step I will generate a block to confirm it. but before confirm I simply check both account's balance.
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance
49.99996240
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance 2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV
0.00000000

And we absolute sure the transaction is submit, so go on.
[frank@localhost bin]$ ./bitcoin-cli -regtest generate 1
[
  "0636e8cba682cc382833923e23028664e49ade44764cdf81b375b59675b84e7e"
]

Okay, We have generate a new block and it's also successful. How about the balance? let check it.
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance 2N6UDwsexfRwRmRYwDFeWjmPvaXtkrsRnFV
0.00000000
[frank@localhost bin]$ ./bitcoin-cli -regtest getbalance
99.99996240

Sadly, I got nothing in the dest account, but the origin account has increment the balance .So my question is how it's going ?

Check to see if the newly generated address is same as the current address - ./bitcoin-cli -regtest getaccountaddress ""

I think it did work, but the getbalance function does not work as you expect. The ./bitcoin-cli -regtest help getbalance reveals that getbalance returns

"The available balance is what the wallet considers currently
  spendable."

The address you generated with ./bitcoin-cli -regtest getnewaddress is probably just a script that routes the funds back into your main account, so it's address is different, but can be spent using the private key in the main account. You can verify this by ./bitcoin-cli -regtest listaccounts and seeing if it returns something like:
{
  "": 10.00000000,
  ...
}

The "" account is the default account, and you can get it's address using: ./bitcoin-cli -regtest getaccountaddress "".
It might be more convenient to generate an address as a new bitcoind wallet account. Try using:
./bitcoin-cli -regtest getaccountaddress "<optional_name>"
Then send the coins to that address and check it's balance using ./bitcoin-cli -regtest listaccounts

Yes, As you said that I have a account with empty string name. So, How can I set a new account to the default account? Also I want to delete that one without name /

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


text:
how is the price of crypto currency computed
how is the price of any cryptocurrency computed, how is the math equation and who actually does it? if you would say a trading site like Coinbase then i say there are also currencies that are i guess not listed in any trading site and still they have a price.
edit: Ask and bid plays the role in the making of price probably. Of course i can sell 1 btc for $1 if i will want, but when selling i have to know what is the worth of it.. and i need to get it from somewhere. If all sellers need to know it from somewhere, where they take it from? You might say again from trading site (again from bid and ask) it is a bit recursion.
Maybe the source is really the biggest trading site.
Maybe the equation is something like:
price = price * ((ask to buy / ask to sell) * unknownIndex)
And ask to buy and ask to sell is made by the popularity / trust (news articles, expectation)

The people, and exchanges? https://coinmarketcap.com/currencies/volume/24-hour/

i am interested in specific math formula answer and also specific answer about how it works with prices for sure

There is no math formula other then Supply X demand?

ok nice, now we are getting closer, yes demand will be probably part of the formula. but you know, the price is strict and specific, so there must be some formula. and almost any crypto currency today has a price.

No, the price is not strict and specific.  The owner of a BTC is free to sell at any price they can get; a buyer is free to offer any price they want.

of course but there is some common consensus :) google "1 btc to usd"

@luky There is no formula. The reported price is just the last price at which two people agreed to perform a trade (or some average over a number of trades). It is not a guarantee that anyone is still buying or selling at that price.

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


text:
Remaining bitcoins sent to a different address
Let's say I have 20 bitcoins in address A. I sent 5 bitcoins from address A to address B. Why is that the remaining bitcoins got sent to address C that I never used or knew before.
I still get access to the remaining 15 bitcoins using the private key of A, but it doesn't show anymore in recipient address A. This is very confusing and would appreciate if someone would clarify.
Also, when I need to receive any bitcoins, which I address should I use? Original address A or address C?

Does this answer your question? How does change work in a bitcoin transaction?

Your bitcoin client must have used a full UTXO to paid for your transactions, since you didnt own the exact amount your bitcoin client created a new private key where it send the remaining ( 20-5 = 15 ) bitcoins, also you had to pay a fees to the miner who mined the block that got your transaction.
To learn more about this process you should go there https://en.bitcoin.it/wiki/Change
If you want to receive new coins, The most private and secure way would be to use a new address given by your wallet, I suggest you to learn about HD wallet who can give you automatically a new address each time you want to receive new bitcoins.

yes, you right, I fixed it


text:
Gift bitcoin more than the annual limit to a friend overseas without tax implications?
If I am gifting my friend say $100k work of bitcoins or any other crypto. Do I have to pay tax apart from the annual limit of $15k. Or will it be cut from my life time limit? My friend he live in a different country, so does he needs to pay tax when he sells this crypto?
Please give me information on this to understand the tax laws and to do nothing illegal.
Best Regards.

Tax laws of what country?  In general, I would expect tax laws to treat a gift of cryptocurrency, or any other valuable property, the same as a cash gift of equal value.  It's an obvious loophole if they don't.  By the way, this question might be more on topic for Money.SE.

tax laws for united states.

if you have 100k to gift to someone, I think you can find a few hundreds to speak with a proper lawyer, who specialize in this situation. Or would you rather listen to some random guy on the internet?


text:
What are the key differences between IOTA and Bitcoin? How are they different?
Please explain:
Whats the key working difference between IOTA and Bitcoin?
How does Tangle differ from Blockchain?
 Or link to some resources that define them.

This question is too broad and shows no research effort. Please read into the subject and ask about specific differences.

I've asked how Blockchain differs from Tangle in functioning and how IOTA is basically different from Bitcoin. Nothing more than that.
Please excuse me If my english was wrong but that was all I wanted to know.
IOTA is new in the game and their website is a bit confusing for me to understand.


text:
Why does electrum need connection to server when recovering a wallet from a seed?
Why does electrum client need connection to server when recovering a wallet from a seed? Isn't the generation of private keys done locally?

Your private information is never shared with the servers and your private keys can always be generated offline.
If you need help doing so, use the #electrum irc channel.
Instructions App:

Start Electrum
Select restore
Enter your seed
Select 'Cancel' in the server selection
Enter a password to encrypt your wallet
Go to settings > Import/Export tab > Private keys: Export

Oh, funny when I tried it first time it kept waiting for server connection.. I probably did not press cancel on Server selection window but disconnected internet connection instead. Yup. Anyway, it works now. Thanks. My bad. :)

While the generation of the private keys can be locally, to recalculate the account's balance tied to the private keys needs data from the distributed ledger (blockchain). As the electrum client does not keep a replica of the ledger it will need access to recalculate the balance of the accounts and hence of the wallet as a whole.

I'm aware of that. The point is that the generation of the private keys is not started without connection to server. If, for some reason, I don't have connection to internet or there are no electrum servers running in the future or something other has fundamentally changed, I should always be able to recover my wallet / private keys, so I can transfer them to other client.

I currently don't see any reason why there should be a reason to require a network connection. So, yes, this ought to be flagged as a defect on the electrum client.

It is actually possible, I just messed up. :) See the other answer from rdymac with my comment


text:
Using dumpprivkey to make a paper backup
I'm just getting started with bitcoin and haven't acquired any significant amount yet, but want to feel relatively secure before I do. And at the moment, my fear of losing bitcoins or a device on which I store bitcoins is slightly greater than my fear of having them stolen so I'm investigating how to make a paper backup. I have looked around and what I have seen seems more complicated than necessary. I am wondering if I could simply:

Start up my bitcoin 0.7.1-beta client
Transfer all my bitcoins to some address in the client
Open the debug window console
Enter walletpassphrase <my passphrase> 60
Enter dumpprivkey <my address with all the bitcoins>
Print the private key that is displayed

Then if I ever need to recover it, I could import that private key into any other bitcoin client. If it's the same bitcoin client newly installed, I could enter importprivkey <my key>.
My one concern about this is that I have somewhere read that some bitcoin wallets "un-steal themselves" and I am worried and wondering if that means that coins may be automatically transferred to another address at some point, at which time my paper backup would become useless.
How wise is this plan? Is there another way I can or should generate a private key and address to which I can send bitcoins without actually having the private key stored on my system if I have a concern about the security of  the system?

If you did this for every receiving address, my understanding is that you would still miss all the bitcoins received to hidden "change" addresses. See http://bitcoin.stackexchange.com/questions/736/how-does-change-work-in-a-bitcoin-transaction

I recommend to check out “bitaddress.org”.
You can grab the whole page (all the java-script it needs is in it) via GitHub and run the brain wallet tab offline.
Type in a damn good pass-phrase and record it. The pass-phrase. Send your bitcoins to the public key that results and re-create the private key with the same pass phrase when you want them.

This is a very interesting and cool page. Still trying to figure out why I want bitcoins more -- because they're a good investment or because the technologies and ideas just seem so cool to me! :) I probably won't use a brain wallet, just a "Single Wallet" -- then I don't have to rely on my fallible memory, and if I should become incapacitated, someone else can make use of my savings.

Probably the most secure thing to do every time I spend anything would be to generate a new "Single Wallet" address and transfer everything I want to keep into that, and then import the private key of the remainder wherever I want to spend it, eh?

I've been under the impression that a paper wallet backup is best for something like a savings account or cold storage. It's impractical to print off the several keypairs that the client generates on initialization (for some clients) or remembering to print out a keypair every time you create a new address, something you should be doing anew for each serious transaction.
Backing up to USB or a NAS or something regularly is the best way to guard against temporary failures. Printing is the best way to keep a balance completely off the network.
If you really want to pursue printing keypairs periodically, you could use something like optar to create a paper wallet that's really just a printed version of wallet.dat. That's more practical and more able to be automated, but still a hassle.

My concern with USB is that I am trying to think of the best way to store coins in a "savings" or "cold storage" account/address, and I know that electronic devices can go bad over time. I want to be sure that if I "forget" about the account for a decade or two, when I come back to it, there won't be any corruption or data loss or compatibility problems preventing me from accessing the account. This isn't something I want to do periodically. I want to be able to send coins to the address and potentially forget it for years at a time.

I don't understand the need to worry about multiple addresses and periodic printing of keys. Can't I just send everything to one address and print the one private key for that address and keep it?

If you're using a paper wallet for a single address for savings, all the talk of periodic backup is moot.

I believe it is feasible way to do that :-)
However, there is a catch: once you have done that, you should not use that wallet for payments. Otherwise you'll risk your funds being moved to some hidden addresses your paper wallet knows nothing about. Every payment you make from the original wallet invalidates your paper wallet. For that reason you may want to backup your wallet.dat on a USB-stick (or CDROM or both) as soon as you print out your paper wallet, for fast retrieval, if needed, and then delete wallet.dat from your hard drive. Putting wallet.dat out of use is a logically consistent step, since the very idea of paper wallet means taking your funds off-line.
You may still send funds to that address of yours, though.


text:
What would happen if PoW cost were drastically reduced or eliminated?
Assuming Bitcoin had a different method for selecting winning nodes and controlling block time creation, please describe step-by-step how the Bitcoin network would be vulnerable to various attacks. How would it play out?
Preferred format:

Bad Actor is selected as winning node
Bad Actor makes changes to an Old Block
Bad Actor re-hashes affected block segments, from Old Block to Last Block — (now possible due to low cost)
Bad Actor processes New Block

Please continue...

Bitcoin does not select a node as a "winner". The truth is agreed to be the longest chain.

By "winning node" I mean the node that completes the mathematical puzzle first. My question suggests evaluating a scenario where POW is essentially eliminated. However, since POW also serves to select a "winning node" to process a new block, as well as setting the time window (10 minutes), this hypothetical assumes alternative mechanisms provide those functions, absent POW.

It think you have your steps of an exploit wrong.  It sounds like you are trying to describe a 51% attack, but are ignoring several factors
First off, step 1 isn't required for steps 2-4 to occur.  A bad actor could make changes to an old block (for example, removing a transaction) and then perform the proof of work on that block and all the blocks on top.  Winning the current block isn't required until all the blocks on top of the edited one are computed and caught up to the current block height (or really chainwork).  So the order of the attack would be step 2, step 3.
Step 4 also isn't really required.  Once the attacker has a longer chain than the rest of the network, she can simply publish their blocks, and other nodes will perform a reorganization.  Whether it's the attacker or someone else that wins the next block doesn't matter.  The edit of a previous block has already occurred, and the attack is complete.
So, in your preferred format:

Bad Actor makes changes to an Old Block
Bad Actor re-hashes affected
block segments, from Old Block to Last Block — (now possible due to
low cost)
Attack complete

The problem with this is that you are assuming that only the attacker has the reduced cost for PoW.  If everyone has access to cheaper hashing, then it doesn't matter that the attacker has access, because she would still have to out-compete the rest of the network combined.  Also, even if the attacker is the only one with access, there's only a limited amount of blocks she can reasonably recompute in a timeframe.  Every 2,016 blocks the difficulty is recalculated based on the amount of time that it took to calculate the previous 2,016 blocks.  If a decent number of those blocks were calculated in secret at this much higher rate, it will increase the difficulty even for blocks calculated in secret.  At some point, the attacker would be making her own job harder.
You may want to read this question to understand better:  What can an attacker with 51% of hash power do?

What would happen if PoW cost were drastically reduced

Blocks would be mined much faster (block time would be much lower). This would have side effects like more orphaned blocks, but to attack the network you'd have to make changes to a much higher number blocks. Effectively the total amount of work would be the same.

What would happen if PoW cost were [eliminated]

An attacker could:

Edit the entire history of transactions in their favor.
No need to redo proof of work because it's not required.
Hope other nodes accept this block among the inevitable barrage of other blocks because there's no consensus requirements if PoW is eliminated.

Note: This would be limited to removing transactions because if the attacker wanted to change values of transactions, they would have to actually resign the transactions, and that would require the private key of the original sender.

JBaczuk, thanks for your response. This scenario assumes there are alternative mechanisms for: 1) regulating block time creation and 2) hashing blocks (i.e. previous block hash, Merkle tree hash, etc.). The POW's hashing function would be preserved for security (linking blocks, etc.), but the computationally intensive search for a nonce would be eliminated. Given these parameters, how could bad actors attack the system? Thanks again!

what is an alternative to hashing a block without actually hashing a block?

Let me rephrase. What would happen if POW difficulty was drastically reduced, but block creation could still be maintained at 10 minutes through some other mechanism?

It depends on that mechanism. Is a random node selected every 10 minutes? Sybil attack. Is it a random block hash selected every 10 minutes? How do you agree on the random block hash? How can you know how to attack a system that isn't defined?


text:
Reject or refuse to relay a valid transaction
Under the Bitcoin protocol, how much control does a node have on how a transaction is dealt with once received? Can a node reject a valid transaction? Can a node refuse to relay a valid transaction to neighboring nodes or is the transaction relayed automatically once validated? If not relayed automatically, why not? Why give a node the option to control whether or not a valid transaction gets relayed?

How do you imagine enforcing a requirement to relay transactions?

Nodes are just software, at the end of the day.
The Bitcoin Core software will automatically relay standard valid transactions provided they meed the minrelayfee.
It would be fairly trivial to modify the software to relay only if certain other rules are met, however. You could easily do this without impacting the rest of the node functionality.
Usually, the node broadcasting a tx will broadcast it to multiple peers, so even if some peers enforce additional relay rules, the transaction will be broadcasted further by those who don't.

Under the Bitcoin protocol, how much control does a node have on how a transaction is dealt with once received?

Look in source code.

Can a node reject a valid transaction?

The node has a right/ability to ignore anything :)

Can a node refuse to relay a valid transaction to neighboring nodes

Yes, it can. Node can do everything coded in algorithm

or is the transaction relayed automatically once validated?

Most of cliens do it.

If not relayed automatically, why not?

Why yes? In decentralized system nobody will punish for it

Why give a node the option to control whether or not a valid transaction gets relayed?

Why not? The presence of such option is better than the absence of it. This gives us on more freedom - to do or not to do

If you run the standard node software, you can expect that they will relay all valid transactions.  A (edit: not only) configurable parameter (in Bitcoin Core) is the minrelayfee.  So you can choose not to relay transactions if the fees are too low.  This is to help prevent spam.
If you wanted to filter on other parameters (e.g. blacklist addresses), this would be easy to do by modifying the software as it is open source.  This would be difficult to detect if a node is doing this, and it would not greatly impact the network unless a vast majority of the nodes started doing this.  Even so, the bootstrap nodes will not do this and such an attack would not be feasible.

there is second configurable parameter -blocksonly


text:
Bitcoin MultiSig balance not showing under listaccounts
I added 2-2 MultiSig address into wallet via bitcoin cli (Testnet)

addmultisigaddress  <'["key","key"]'> [account]

1 key of current wallet and other public key from different node wallet.
Account is showing

0.000000

Although more than six confirmations on the transaction: https://live.blockcypher.com/btc-testnet/tx/297b6f6c14486e9eda1b2a04e20e3bd161758afeafa7d4b0109fa7fca11154ae/
Most importantly listaccounts not listing the account associated with the MultiSig address.
getaddressesbyaccount [MultiSigAccount] shows the MultiSig address created above.
How can I get the balance of MultiSig address via bitcoin-cli?
Edit 1:
What does this command return: $ bitcoin-cli -testnet validateaddress <your-multisig-address>?

{
  "isvalid": true,
  "address": "2Mv4iYeyQtVV1M7rqzgUc68QzQ21vy1o36Z",
  "scriptPubKey": "a9141eeba411eae41a1a3dc7456ec4d599aef84afd7687",
  "ismine": false,
  "iswatchonly": true,
  "isscript": true,
  "iswitness": false,
  "script": "witness_v0_scripthash",
  "hex": "00206e908e1cca44b136fbf666f356114ca6a84c1fbed0327a155c204580310a7a11",
  "embedded": {
    "isscript": true,
    "iswitness": true,
    "witness_version": 0,
    "witness_program": "6e908e1cca44b136fbf666f356114ca6a84c1fbed0327a155c204580310a7a11",
    "script": "multisig",
    "hex": "52210240d4ae4819e35e346560efe665f79453210a0b26184e08705964c5eb89e885ca2103fcc7e4690f7bd3a51db7ed438ef9a7ffb0bf316467f39b384935befee4eb208552ae",
    "sigsrequired": 2,
    "pubkeys": [
      "0240d4ae4819e35e346560efe665f79453210a0b26184e08705964c5eb89e885ca",
      "03fcc7e4690f7bd3a51db7ed438ef9a7ffb0bf316467f39b384935befee4eb2085"
    ],
    "address": "tb1qd6ggu8x2gjcnd7lkvme4vy2v565yc8a76qe8592uypzcqvg20ggslwnwl8",
    "scriptPubKey": "00206e908e1cca44b136fbf666f356114ca6a84c1fbed0327a155c204580310a7a11"
  },
  "addresses": [
    "tb1qd6ggu8x2gjcnd7lkvme4vy2v565yc8a76qe8592uypzcqvg20ggslwnwl8"
  ],
  "account": "multisig22",
  "timestamp": 0
}

The documentation on addmultisigaddress states:

This functionality is only intended for use with non-watchonly
  addresses. See importaddress for watchonly p2sh address support.

Since the wallet does not have both private keys, it won't show a balance unless you use importaddress. Note the ismine: false property in validateaddress, that means your wallet doesn't have ability to spend (doesn't have private keys).
addmultisigaddress nrequired ["key",...] ( "account" "address_type" )

Add a nrequired-to-sign multisignature address to the wallet. Requires
a new wallet backup. Each key is a Bitcoin address or hex-encoded
public key. This functionality is only intended for use with
non-watchonly addresses. See `importaddress` for watchonly p2sh
address support. If 'account' is specified (DEPRECATED), assign
address to that account.

To watch a multisig address (get it's balance), you should use importaddress:
importaddress "address" ( "label" rescan p2sh )

Adds a script (in hex) or address that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.

Arguments:
1. "script"           (string, required) The hex-encoded script (or address)
2. "label"            (string, optional, default="") An optional label
3. rescan               (boolean, optional, default=true) Rescan the wallet for transactions
4. p2sh                 (boolean, optional, default=false) Add the P2SH version of the script as well

Note: This call can take minutes to complete if rescan is true, during that time, other rpc calls may report that the imported address exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes. If you have the full public key, you should call importpubkey instead of this.

Note: If you import a non-standard raw script in hex form, outputs sending to it will be treated as change, and not show up in many RPCs.

Examples:

Import a script with rescan
> bitcoin-cli importaddress "myscript"

Import using a label without rescan
> bitcoin-cli importaddress "myscript" "testing" false

As a JSON-RPC call
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "importaddress", "params": ["myscript", "testing", false] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

After calling importaddress account balance was still showing 0.00000 by getbalance [MultiSigAccount]
To check the balance of the MultiSig address this one worked and showing the balance of the MultiSig address after importaddress call:

bitcoin-cli -testnet getreceivedbyaddress [MultiSigAddress]


text:
MultiSig address transaction high fee with no change
I was testing MultiSig transaction on testnet with raw transactions. I sent a transaction of 0.0012 from MultiSig 2-2 to a bitcoin address:

https://live.blockcypher.com/btc-testnet/tx/2aa89b860e677d17af65ac6d0e44aa9fb20dc7698d5b96e348c8bced839834c3/

The transaction consumed remaining in the transaction fee than returning any change which is very high than actual amount transferred.
Should I need to specify the fee for the transaction as well while keeping the same MultiSig 2-2 P2SH address for change.

Fees for multisig addresses (or P2SH in general) work exactly the same way as they do for P2PKH addresses. The fee is simply the difference between the inputs and the outputs.
In  your transaction, you only have one output, so by definition any left over amount is converted to fees. If you want to spend less, you simply need to add in a change output to another address you control, such that total input - total output = fee you want to pay.
There is no difference based on what type of address you use in how fees are calculated. Try setting your wallet/code to send the balance to a change output (I don't know of any wallet that doesn't do this)


text:
P2TR script-path multisig
With bitcoin-cli, I successfully spent (broadcast, was accepted by the regtest node and then mined) a tx spending two 1-of-2 script-path multisig outputs.
The spent prevout descriptors were:
tr(<unspendable_bip341_key>,multi_a(1,<even-parity-33-byte-key1>,<odd-parity-33-byte-key2>))
After the spending transaction was mined into a block, I viewed the multisig script: bitcoin-cli -regtest decodescript <tapscript> where <tapscript> was the penultimate element of the input witness stack. I got:
{
  "asm": "<x-only-32-bytes-of-key1> OP_CHECKSIG <x-only-32-bytes-of-key2> OP_CHECKSIGADD 1 OP_NUMEQUAL",
  "desc": "raw(<hex>)#<checksum>",
  "type": "nonstandard"
}

My questions are:

Apparently, it's expected that the parity (first 0x02 or 0x03) byte is dropped from the 33 byte keys that I put in the descriptors, when I created the output. The keys become 32-byte x-only keys. When spending and verifying this, how does it recover the parity information, it appears to be lost in the decoded tapscript?
Why does decodescript return nonstandard? My core version is v0.25, and the spent prevout was created by its bitcon-cli.
btcdeb refuses to validate this script. This could be due to btcdeb being on the v0.24 still, however.

Yes, the conversion from descriptor to script converts the keys to x-only form, because that is the only public key format supported inside tapscript. There is no parity information to recover; these are the full public keys as far as the BIP340 signature scheme is concerned.

This script would be nonstandard when placed in a scriptPubKey directly. Inside tapscript, p2wsh, and p2sh, almost any script is permitted by policy.

I am unfamiliar with btcdeb.


text:
Manage multiple users wallets for web wallet service
This already summaries the issue I'm currently trying to figure out to calculate the transaction fee to prevent negative balance.
(testnet) I tried using createrawtransaction answered.
When I tried to send all balance to an address, the txid was created successfully using createrawtransaction but when I ran the fundrawtranaction on that txid it showed
error code: -4
error message:
Insufficient funds

The goal is to calculate transaction fee before hand to check either sufficient balance is available of an account using sendfrom
To manage multiple users to isolate users' balances as this.
EDIT1:
If using estimatesmartfee it is showing the fee:
bitcoin-cli -testnet estimatesmartfee 6
{
  "feerate": 0.00501921,
  "blocks": 6
}

When calling sendfrom for total balance transfer:
bitcoin-cli -testnet sendfrom <account> <address> <amount>
error code: -4
error message:
Error: This transaction requires a transaction fee of at least 0.00067257

Is there a way to get 0.00067257 the fee part before send the transaction amount and set it so that account balance won't go negative for multi accounts wallet.
Edit 2:
I found out that accounts are deprecated.
And multi wallet creation/load/unload on runtime is underway to 0.17.0
So what would be the best approach to handle multiple users bitcoins in isolation on a full node to prevent negative balance.

You can do estimatesmartfee 6 to calculate suggested BTC/kB fee aiming confirmation in six blocks. Then you can do fundrawtransaction <tx> "{feeRate: 0.000something}" to add inputs with the specified fee. This way, you'll have more control over the fees.


text:
Using CryptoCurrencies as a transfer method throughout Australia and Europe
I have read both this questions:
Can I easily use Bitcoin as a inexpensive way to transfer my money into another currency?

Does it make sense to use BitCoin to transfer money to yourself internationally?
Which both do answer yes to the questions, both answered by @Murch and others ofcourse.
Those questions where done a long time ago, and I'm sure things have changed and improved.
The situation is: I have my cousin in Australia, where he has money there. We would like to transfer it to Euro and I thought we could do it using Coinbase.
Could we just exchange the money to ETH or BTC with AUD and then once in Europe transfer it to a Bank here.
Would that be cheaper than using transferWise or throughout bank transaction? (As far as I can think of, it would be only Coinbase fees on deposit and currency exchange which might differ... Or maybe something else)
We don't actually care about the amount of time that we spend with the transaction.

I think you should look into Stable Coins such as USDC or USDT. These are crypto pegged to the US Dollar. BTC and ETH (and hundreds of others) markets are very volatile, it's not outwith the realms of possibility that by the time you are ready to convert your money back to fiat..... it's +10% or -10% what you started with.

I know about that, it's a loss/profit we would like to look for. If we do it, we would wait for the great moment.

The most "profitable" way i can think of doing this is:
1) Your cousin buy BTC with AUD in Australia in some local exchange (preferrable) or at LocalBitcoins.com
2) You sell the BTC in Europe using LocalBitcoins (your cousin will give you the password for his LBC account or transfer the BTCs to your account there). They have a 1% fee for sellers, but you could just advertise with a 1% profit, or even more, because prices in LBC are usually higher than at local exchanges. In my country i can easily sell with up to 3% profit.

No expensive international bank fees
You receive the money directly in your bank account

I don't know if using Stable coins would be a good idea, as you'd probably have to pay some convertion fee to redeem them in Europe.
Anyways, it will mostly depend on the volume you're dealing with and the time you've available.
For example, i don't think it will be easy to sell ~300 BTC in LocalBitcoins.
I think the most sensitive part is selling the coins (it's the part the fees are usually higher). If you're dealing with higher volumes you should probably look for a local OTC desk (exchanges have that and the fees are negotiable).


text:
How to make a persistent SPV wallet? (bcoin)
I created a wallet on a SPV node. The wallet is initialized from a mnemonic. After receiving some transactions, the wallet's balance looks like:
{ account: -1, tx: 3, coin: 3, unconfirmed: 136300, confirmed: 0 }

But when I re-initialize the wallet, it looks so:

{ account: -1, tx: 0, coin: 0, unconfirmed: 0, confirmed: 0 }

On the each initialization the wallet have the same address.
Here is my code:
const bcoin = require('bcoin');
bcoin.set('testnet');
const KeyRing = bcoin.keyring;
const Mnemonic = bcoin.hd.Mnemonic;
const HD = bcoin.hd;

const node = new bcoin.node.SPVNode({
    config: true,
    argv: true,
    env: true,
    logFile: true,
    logConsole: true,
    logLevel: 'debug',
    db: 'leveldb',
    memory: false,
    persistent: true,
    workers: true,
    listen: true,
    loader: require,
    network: 'testnet'
});

// Temporary hack
if (!node.has('walletdb')) {
    const plugin = require('./node_modules/bcoin/lib/wallet/plugin');
    node.use(plugin);
}

process.on('unhandledRejection', (err, promise) => {
  throw err;
});

const walletdb = new bcoin.wallet.WalletDB({ memory: false, network: 'testnet', prefix: '/Users/alestsurko/.bcoin/spvchain' });

(async () => {
    await node.ensure();
    await node.open();
    await node.connect();
    await walletdb.open();
    const mnemonic = new Mnemonic('uncover cash coral neglect upon nurse argue deal right song hood tennis');
    const masterKey = HD.fromMnemonic(mnemonic);

    const wallet = await walletdb.create({master: masterKey});

    console.log('Created wallet with address %s', await wallet.receiveAddress());
    const bl = await wallet.getBalance();
    console.log(bl.toJSON());

    // Add our address to the spv filter.
    node.pool.watchAddress(await wallet.receiveAddress());

    node.startSync();

    node.on('error', async (err) => {
        console.log(err);
    });

    node.pool.on('tx', async (tx) => {
        console.log('------ New tx. Adding to walletdb...');
        console.log(tx);
        await walletdb.addTX(tx);
    });

    wallet.on('balance', async (balance) => {
        console.log('Balance updated.');
        console.log(balance.toJSON());
    });
})().catch((err) => {
    console.error(err.stack);
    process.exit(1);
});

As commented here, the cause of the problem is that I

sorta have created two wallets. The first is instantiated by the plugin statement towards the top, and then you also create a new walletDB right after.

So the solution is using WalletClient:
const {WalletClient} = require('bclient');
const {Network} = require('bcoin');
const network = Network.get('regtest');

const walletOptions = {
  network: network.type,
  port: network.walletPort,
  apiKey: 'api-key'
}

const walletClient = new WalletClient(walletOptions);
const id = 'primary'; // or whatever your wallet name is
const wallet = walletClient.wallet(id);

Instead of walletdb.create().


text:
Can you create multiple transactions per block in chronological order?
Say I buy a coffee mug, a box of tea bags, and a half liter of honey in the span of five minutes using Bitcoin.
Since the Bitcoin network creates a block every ten minutes or so, these transactions will be within one single block.
Once the block containing the transactions is created can I use a blockchain explorer to view the transactions in chronological order?

Yes. The transactions will be in the correct order chronologically, or else block validation would fail because there would be missing inputs to the transactions out of order. See Is there a fixed order for all transactions in the block chain?
Another way to do this is to see which previous outputs each transaction references. If they are in the same block, they will reference each other and you can determine order that way. See also Can multiple transactions transferring the same bitcoin be done in one block?. You cannot use a timestamp, because the block is what is timestamped, so all transactions in the block have the same timestamp.

Great answer! Brownie points; will this work sending multiple transactions to yourself (same Bitcoin address)?

Yes, it happens with change transactions and dust sweeping.

You're the best.

fyi: Those transactions do not necessarly need to be in the order in the blockchain as the order you created them! It is possible that there is a TX from A->B and a TX B->C and in the bitcoin blockchain the transactions are stored in the order B->C, A->B (within the same block).

What about this: "the protocol enforces that the transactions will be written out in the block in the correct order." https://bitcoin.stackexchange.com/questions/23035/order-of-transactions-within-a-block/23070#comment35633_23070


text:
UTXOs set size for small node
For several months the size of the UTXOs set has been exploding with almost 20MB more every day. So I would like to know from what size it may be a problem for small nodes such as Raspberry Pi 4 for example?

Bitcoin Core adds outputs to the UTXO cache either when they are newly created, or when they’re spent by inputs in transactions the node learns about. Whenever the node’s dbcache is full, it flushes the entire cache and starts over. A larger UTXO set means that a smaller portion of them can fit into the cache before the cache gets flushed. This especially slows down IBD, but may also slow down node operation at some point.
I would expect that node performance would degrade gradually rather than at some specific point.


text:
Bitcoin chain reorganization
When two blocks are mined and propagated at similar times times causing a fork, how long would a node store a stale chain until considered orphaned?

How many blocks (work) are needed on chain I for chain H to be discarded?

Bitcoin Core will never discard reorged blocks, until they are pruned (which happens regardless of whether the blocks are in the active chain or not).
Only one chain is considered "active" at a time though. The rules are:

Only consider fully valid chains (i.e. if a block contains an invalid signature or anything else illegal, it is ignored, together with all its descendants).
Among those valid chains, only the one whose tip has the most accumulated work (roughly equal to the sum of the difficulties in the chain) is considered.
If there are multiple valid tips of equal accumulated work, the one whose last block was received first is considered active.

All other chains are considered inactive, but if they get extended, they may end up becoming active again.

Thank you.
By pruning, do you mean the optional pruning mode to save disk space?

Yes, indeed. It just removes all old blocks past some threshold of age, regardless of whether they are part of the active chain or not.


text:
Does anyone know anything about this bitcoin bouns cloud mining emails I am getting?
memo BOSA asara@abv.bg
Attachments
4:35 PM (4 hours ago)
to marszaleknowiny

My name Lisa Davis, I am senior director of Bitcoin Bonus
Evening late (the day before) you received an automatic smessage from us about the status of your wallet.
We would like to remind you that you authorized with us 1 year ago ≈375 days ago,.
Your account and the server capacities you have reserved have been working all year
You have 1.48283 BTC saved in your account, which is equivalent to 29,383 at the current exchange rate.
Please note that our company is currently changing its legal status and reorganizing into a new legal entity.
According to our company rules, if a client does not withdraw his earned money within a year, his account can be blocked.
You urgently need to activate your account and withdraw money .
We can see that you have already tried to withdraw your funds and were unable to do so.
Most probably, the possibility of paying by credit card is not available in your country, so we can offer you the possibility to pay by Bitcoin .
Please be reminded that after 21:11:32 your account may be blockedk5iNCOi99.
To withdraw funds login to personal account.
Details, in attached to the letter file
If you ignore our message
And you will not make transfer within 23:55:121 .
Your account will then be blocked and your funds will be zeroed.
Sincerely,  bitcoin bonus
More details about registration:
Sender: 7258****9964
Authorization code: 21985027
P/C: 15472257731844658768581689
TIN: 739228900547
BIC: 2340083637959
One attachment
•  Scanned by Gmail

Its spam, aiming at getting the unwary scammed. Mark it as spam and delete it. Its a variation of the old "someone died and we need to give the money to someone" scam.


text:
How does fee split between senders in a transaction?
I know how fee is calculated in a transaction,
but I don't know how this fee amount split into senders.
For example, consider the following transaction with 0 BTC miner fee:

inputs:
   Alice    sends     20 BTC ->
   Bob      sends     10 BTC ->

miner fee: 0 BTC
outputs:
-> Carol   receives   15 BTC
-> Alice   receives   10 BTC
-> Bob     receives   5  BTC

Now if we consider 1 BTC for miner fee , how does these output amounts change?
Maybe in half?
-> Carol   receives   15  BTC
-> Alice   receives   9.5 BTC
-> Bob     receives   4.5 BTC

There is no real concept of sender identities, as far as the blockchain is concerned. The fee split is entirely determined by the change output values, which are entirely determined by the signers of the transaction.
A transaction involving inputs from two separate parties will require some coordination between them to decide on the recipient and change. It is presumed that during this coordination, a fee is decided upon, and set.
Bitcoin itself offers no insight into this splitting process, it should be handled out of band by the wallet or tool used to construct the transaction, based on configuration from the senders


text:
How to test if a transaction can spend an existing output?
Suppose I'm writing a transaction by hand, that spends an existing uspent output sent by myself from another address. Is there a way to test if the transaction can really spend that output, before brodcasting? The reason is, I want to be sure if I'm correctly generating the sigScript.
EDIT: I know it is possible to syntactically verify transactions, but I'm asking if do exists a method such as canSpend(myTransaction, unspentOutput). Ideally that would execute the combination of scripts myTransaction.sigScript and unspentOutput.ScriptPubKey and check if the result is true.

If you build Bitcoin Core from master, you can use the new testmempoolaccept rpc method to check if your tx would have made it into the mempool. This will include checking the signature, and ensuring that your inputs are actually unspent. It does not add broadcast the tx into the mempool, but simply checks if it would have been accepted.

does it test also if sigScript + ScriptPubKey return true, so if the transaction really can spend that input?

It should, yes. A bad script will not be accepted into the mempool

This Python library has a verify() method that will run the script and perform a few trivial checks.
from btctools import Transaction
>>> tx = Transaction.from_hex('0100000000010153159b2a077d8dfbe4dca4b6b3a9e0ccedb4962ca73280526e6a1eeb1e8e9adc2a00000000ffffffff04a08f3e00000000001976a914de755835002260891962f1e671a2bf7605788d0f88ac0046c3230000000017a914c7c9b5f51244f39f81ec01146eb0d1d98d4bbd4c872052a6000000000017a91469f376599f0ffcaacd6a79854b1ee99513bb7b35870006f21600000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d04004830450221009360af3ec3f9d4ae8acc3ab2213f3f9344cb322b4ea447490bb297a9a4c1d207022067027b032e54b3efb9e885604349ec4f1b6446eed8ed208c6fe6eeae9ace921a0148304502210097cf932eb37513c201b577472d70f1553f338d6439e9181607ec75f2e83fa148022052368c88085838521efc64cf509b95dd53d8c825089acd3ff681e74d3a2b4959016952210266edd4ef2953675faf0662c088a7f620935807d200d65387290b31648e51e253210372ce38027ee95c98cdc54172964fa3aecf9f24b85c139d3d203365d6b691d0502103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000')
>>> tx
Transaction(inputs=1, outputs=4)
>>> tx.verify()
True
>>> tx.outputs[0].json()
{'scriptPubKey': {'address': '3KuQ2pyr5LHwiU1a2Rwrn9kGGMpUmHxLdm',
 'asm': 'OP_HASH160 c7c9b5f51244f39f81ec01146eb0d1d98d4bbd4c OP_EQUAL',
 'hex': 'a914c7c9b5f51244f39f81ec01146eb0d1d98d4bbd4c87',
 'type': 'P2SH'},
 'value': 6.0}
>>> tx.outputs[0].value += 1
>>> tx.verify()
False

Thanks. It does not look like what I'm asking for, I edited the quesiton.

@robermann I read your edit. You want something to validate that the script executes and results in a single True on the stack. That is what the library does. Maybe I didn't show a good example in my post.

I tested it, it works (but doesn't recognize OP_RETURN data)

Just for reference, there is also a static method in NBitcoin in class Script:

public static bool VerifyScript


text:
OP_RETURN max bytes clarification
I've read that an OP_RETURN opcode allows up to 80 arbitrary bytes to be used in an unspendable transaction.
My question is, how is it possible that in this famous transaction (d29c9c0e8e4d2a9790922af73f0b8d51f0bd4bb19940d9cf910ead8fbe85bc9b) are being pushed 983 bytes?
In detail:
 Push data having size of 893 bytes. OP_CODES:

     6a             4d                    d7 03
 OP_RETURN    OP_PUSHDATA2    (03d7 = 983 following bytes)

The limitation is a relay standard, but not a consensus rule. This can be modified on a per-node basis with $ bicoind -datacarriersize flag. The consensus rule that would limit this is the max block size, if I'm not mistaken. So, presumably, miners connected to the node that accepted that non-standard transaction mined that block, thus it was non-standard, but still valid.
Standards
These rules are enforced during mempool acceptance. Each node can decide to implement different rules, provided they follow consensus rules, but many just accept the Bitcoin-core defaults upon installation. In this case 80 bytes is the default setting for OP_RETURN data size.
Consensus Rules
These rules are enforced at the block validation phase. These cannot be different between nodes or it would be considered a hard fork and the chains would diverge.

presumably, miners connected to the node that accepted that non-standard transaction mined that block, thus it was non-standard, but still valid: why a miner would accept to do such a thing? In order to gain its fee (0.008 in this case)?

Possibly, or maybe the person mining is the same person running the node, and they wanted to post that data.

Yes, it was in 2013, probably the mining task was not such difficult as today, and a developer could afford mining himself.


text:
How to perform atomic swap Bitcoin-Litecoin
I am running Bitcoin and Litecoin nodes fully synced on testnet.Can I perform atomic swapping by using this networks?
I heard it can be done through HTLC(Hash Time Locked Contracts). How can I do exactly by HTLC and trying to go deeper in to HTLC?
Thanks.

You would need to find another party to do the swap. An example:
Alice and Bob have accounts on both chains. Alice has Litecoin that she wants to exchange into Bitcoin. Bob has Bitcoin that he wants to trade for Litecoin.
Alice tells Bob that she is willing to give him 2.5 Litecoin for 1 Bitcoin. Bob agrees. They both agree that Alice will publish a contract on the Litecoin blockchain that transfers 2.5 Litecoin from Alice to Bob.
Once the Litecoin contract is published, Bob examines it. He sees that the parameters are to his liking, so he publishes a contract on the Bitcoin blockchain that transfers 1 Bitcoin from Bob to Alice.
Alice examines the Bitcoin contract, and likes what she sees. She uses the preimage that she used to build the Litecoin contract to unlock the 1 Bitcoin. Bob is no longer the owner of the 1 Bitcoin.
When Alice used her preimage, that preimage was published on the Bitcoin blockchain. Bob sees it, and uses the same preimage to unlock the 2.5 Litecoin on the Litecoin blockchain.
That example is a simplified version of the typical scenario, but I hope it helps you see the coordination required to do an HTLC.
A little more detail into the mechanisms can be found on a writeup I did for HTLCs between the Bitcoin and Bitshares blockchains. It can be found at http://www.jmjatlanta.com/index.php/2018/09/27/bitshares-and-hashed-time-lock-contracts-htlc
If you are looking for more technical how-to, you can use the following resource:
HTLC (Hash Time Lock Contract) using bitcoin-qt
I use the libbitcoin library for BTC. A tutorial that can get you started with HTLCs using that library can be found at http://aaronjaramillo.org/libbitcoin-cross-chain-swaps-with-htlcs


text:
How long for Bitcoin core to initially synchronise?
Now i tried sweeping with my private key but its says needed to confirm output no output

how long will [Bitcoin core] take to sync?

How long it takes to sync depends on your computer and your network connection.
It may take a week.
Bitcoin core will give you an estimate - but that assumes the computer is never turned off, never sleeps, hibernates or drops into a low-power mode and never runs other CPU-intensive tasks while core is syncing.

is there a way to get the bitcoin out incase

in case of what?
You can export the private key and then import it into a lightweight (SPV) wallet which will allow you to spend your BTC without needing to download and verify the whole blockchain first.
See

https://bitcoin.stackexchange.com/a/78758/13866 which covers debug console commands
listreceivedbyaddress 0 true
dumpprivkey <address>

How can I export the private key for an address from the satoshi client?
List of wallets showing which support SPV

I tried sweeping now with my private key but its says needed to confirm output whats dies it mean pleas

@Olamilekan: You are new here but the main purpose of this website is to create a set of questions and answers that other people with the same problems will also find useful. By editing your original question and changing it completely you have undermined this. If you have a follow-on question, please use the "Ask Question" button above to ask a new question. You can put a link to this question in the new question if you feel it is relevant. You can "roll back" an edit if you change your mind (use "roll back" link in the edit history)

I dont know how to use it am sorry Okay i will but please before that let me explain better  my bitcoincore is syn and i have my bitcoin in it so from the videos i watched on youtube i went took the reciving address and paste in debuorg and i got a private key and i firstly i paste the private key on a sweep website and the new address i want to send it too and it saying no utxo for this addres and i also tried it on electrum is says no output needed to confirm the output thays what prompt my question is there anything i need to do thanks

If you pasted your private key into a website you have given your bitcoins to the people who run that website. It isn't clear what exactly you have done. I suggest you start a new question and paste in all the addresses you used. Do not paste your private key anywhere. Explain exactly which websites you used. Post screenshots of messages you want help with.

I dont really know how to use this app to put the screenshot but the site it (sweepkey.org) but i tried to check the address i sent my coin to on blockchain it shows it has only 1 transaction and theres balance there what do you think

Sweepkey.org is the name of the site and i tried to get the address i sent my coin to in my bitcoin core and i checked it on blockchain it has only 1 transaction and it still has the same balance i sent is there any chance i wont meet my money when my bitcoin core finish syn


text:
Raw Transaction Fee - 256: absurdly-high-fee error
I'm running the following codes, respectively.
 bitcoin-cli -testnet createrawtransaction '''
 [
    {
      "txid":"751b6361cd8d621de00466363120e5da2176c3cc092cb3f0b7373b02591372d2",
      "vout" : 0
    }
 ]''' '{ "2N2VoHPMHT8CBYrhJqhJj1uauPaxMN7Qqed": 0.001 }'

response;
0200000001d2721359023b37b7f0b32c09ccc37621dae52031366604e01d628dcd61631b750000000000ffffffff02a08601000000000017a914657abfa90bd62f0f7a9533509b855cfd5f6e7d178750c300000000000017a91477c7f1a5a522daf70274dab6cdcb85efcc6e99318700000000

My DecodeRawTransaction output;
 array:8 [▼
      "txid" => "8608e07487a15b8866496bd5e90c92736d909a8b3023e1cfc75481e613164fe7"
      "hash" => "8608e07487a15b8866496bd5e90c92736d909a8b3023e1cfc75481e613164fe7"
      "version" => 2
      "size" => 83
      "vsize" => 83
      "locktime" => 0
      "vin" => array:1 [▼
           0 => array:4 [▼
                "txid" => "751b6361cd8d621de00466363120e5da2176c3cc092cb3f0b7373b02591372d2"
                "vout" => 0
                "scriptSig" => array:2 [▼
                     "asm" => ""
                     "hex" => ""
                ]
                "sequence" => 4294967295
           ]
      ]
      "vout" => array:1 [▼
           0 => array:3 [▼
                "value" => 0.001
                "n" => 0
                "scriptPubKey" => array:5 [▼
                     "asm" => "OP_HASH160 657abfa90bd62f0f7a9533509b855cfd5f6e7d17 OP_EQUAL"
                     "hex" => "a914657abfa90bd62f0f7a9533509b855cfd5f6e7d1787"
                     "reqSigs" => 1
                     "type" => "scripthash"
                     "addresses" => array:1 [▼
                          0 => "2N2VoHPMHT8CBYrhJqhJj1uauPaxMN7Qqed"
                     ]
                ]
           ]
      ]
 ]

After, I'm running this command;
 signrawtransaction 0200000001d2721359023b37b7f0b32c09ccc37621dae52031366604e01d628dcd61631b750000000000ffffffff02a08601000000000017a914657abfa90bd62f0f7a9533509b855cfd5f6e7d178750c300000000000017a91477c7f1a5a522daf70274dab6cdcb85efcc6e99318700000000

And finally, I'm running the SendRawTransaction command.
bitcoin-cli -testnet sendrawtransaction 02000000000101d2721359023b37b7f0b32c09ccc37621dae52031366604e01d628dcd61631b75000000001716001466c18ec25251afe44f6a9f99be78b4e04857ef46ffffffff01a08601000000000017a914657abfa90bd62f0f7a9533509b855cfd5f6e7d178702483045022100b0291f0c753b3876a7d0d5c8970caa0e4b70cad224de9248377054e342ad1ed1022006de0d6e07991319ce467e5550bb203e4d398452c457b138e1fb5b7a3b2e9427012103f382a14da980fba9234d02599fe5ced7b1f907385d1d14bfb17017e5cfdc318500000000

And I get this error;
 256: absurdly-high-fee

Can anyone help me?

My problem is still continuing. The relevant content did not help.

you are spending a 0.15 btc output and only sending 0.01 btc the rest 0.14 will implicitly go as a fee to the miner which is very high so you get an error. You need to add a second output with where do you want the 0.14 btc to go.

The fee is calculated from the difference between vin and vout. Here you are sending a very small amount to an addresses but you have not specified an output to receive the change. The client sees this change as the fee which is probably very large.
You need to create a separate vout to send the change from the transaction, leaving a small amount for the fee.

Thank you for replying. I don't know much about it. How do I create vout?

You already have a vout: { "2N2VoHPMHT8CBYrhJqhJj1uauPaxMN7Qqed": 0.001 }

Create another one where the address belongs to your wallet (bitcoin-cli getnewaddress) and the value is the change minus a fee

You should be able to find the value of the vin by searching for the txid: 751b6361cd8d621de00466363120e5da2176c3cc092cb3f0b7373b02591372d2

You could alternatively use the sendtoaddress rpc call

I'm trying, but I haven't succeeded. :(
From adress is: 2N4ZgDkNDUqo5aHADMxW2qHUahC51g6FVYY (751b6361cd8d621de00466363120e5da2176c3cc092cb3f0b7373b02591372d2)
To address is: 2N2VoHPMHT8CBYrhJqhJj1uauPaxMN7Qqed
Can you show me an example? Thank you for helping.

bitcoin-cli -testnet createrawtransaction '''
[
{
"txid":"751b6361cd8d621de00466363120e5da2176c3cc092cb3f0b7373b02591372d2",
"vout" : 0
}
]''' '{ "2N2VoHPMHT8CBYrhJqhJj1uauPaxMN7Qqed": 0.001,
"change_address": vin_value - 0.001 - fee}'

Thank you so much. What is the difference between sendfrom and createrawtransaction? Which is safer?

With sendtoaddress input coins and fee are chosen automatically. With createrawtransaction you have the option which inputs to use and how exactly to structure outputs and fee.


text:
Who proposed the XBT ticker for Bitcoin and why is it used over the more logical XBC ticker?
Some standard requires tickers for currencies to start with an X. So, the usual abbreviation of Bitcoin, BTC, cannot be used in contexts where this standard is applied.
Usually, the unofficial ticker/abbreviation XBT is used in those contexts. Why? Bitcoin consists of two words, bit and coin, it's logical to abbreviate that to BC. For this reason XBC sounds like a much more logical ticker than XBT.
What is the first reference of XBT and is a consideration made before using it that favoured it above XBC?

XBT was proposed as part of ISO 4217, where the 'X' stands for "non-governmental unit".

XBT is used because the ISO 4217 (the standard for currency codes) alphabetic code XBC is already in use.  It stands for the European Unit of Account.
Here's the Official table of ISO 4217 codes
The X indicates it's not a national currency, but rather a supranational currency (like the East Caribbean Dollar, XCD) or something else that isn't quite a currency, like IMF special drawing rights (XDR) or precious metals (XAU is gold, XAG is silver, etc.) for which exchange rates are of interest.
X is used for this because ISO 3166, the standard for country codes, never uses X as the first letter and the currency code is the 2 letter code and usually the first letter of the currency name.  For example, JP is the code for Japan, so the code for the Yen is JPY.  An exception example is the Mexican Peso, code MXN.  MX is the code for Mexico, and the N stands for New Peso.

How is MXN an exception? Many countries have had “new” currencies, that make their ISO 4217 code XXN, with XX being the country code.

XBC is used by a POS coin called bitcoinplus.

XBT was used before BitcoinPlus's first block. I don't think that's it.

Yeah, I'm pretty sure most haven't even heard of this altcoin.


text:
input and outputs different address in the same wallet but address not exist!
Dear Bitcoin Community members. I am using Bitcoin Core version v24.0.1.
I have recieved funds to this address: bc1qfewsp4zw738qd26a5wsgsq3j8hmjau5zz4d8je
I have sent funds using SendMany function with this txId:
ec5b35a5f0e237781f5d47d39e3fc3bf06f99edfe5670c2496b4e2748bfcc661
It seems my funds not sent from the address that I have received and sender address not belong to any of address I have seen in my wallet.
Despite that I have made many successful transactions, today I have noticed, one of my transaction received by one address, and sent by another! However there is no internal transactions.
When I search by blockchain explorer, I don`t see any connection about fund!
What could be the problem? I have asked ChatGtp, he has warned if my account is compromised!.
Kind Regards

According to its makers "ChatGPT sometimes writes plausible-sounding but incorrect or nonsensical answers." - it is more an experiment in language processing that has very little access to truth. I would not rely on it at all. It is a charming liar, as happy to deceive as to inform.

Thank you for clarifying. It is true most cases. But It is good to listen sometimes giving valuable information.

The sendmany RPC takes a JSON object of key-value pairs, where the key is the bitcoin address you are sending to and the value is the amount to send to that address. The inputs are automatically chosen by the wallet. For more information, check bitcoin-cli help sendmany.
If you want to specify which UTXOs to use as inputs in a transaction, you can use the send RPC and pass a list of inputs in the options object. You will need to know the transaction ids and vouts of the UTXOs you want to spend, which you can get by running bitcoin-cli listunspent. See bitcoin-cli help send and bitcoin-cli help listunspent for more information and examples.
With regards to your transaction, I can see that you specified three outputs to spend to and your wallet automatically chose an input to fund the transaction.

Send function warning like "Experimental" makes me scared to try, but Thanks for the detailed info. I will make some trials.

You can always practice using these commands on signet or testnet and I strongly recommend doing so before using the commands with real money on mainnet.

Thanks Josie for your valuable comments and time.


text:
ListWalletDir: Access is denied D:\System Volume Information
My BTC Core wallet is not yet fully synchronized, now I got this message in the debug Notepad ''List Wallet Dir: Access is denied D:\System Volume Information'' and whenever I move the mouse over the left tab, it stops at open Wallet and nothing works anymore it will not responding and I need to close the Wallet, I hate Btc core Wallet because it's my second time now I downloaded at a new Laptop and I got another Bug again.

Access is denied is not a bug, but the software in your system hasn't permission to write to the disk. I think that your bug is related to your system configuration.

@vincenzopalazzo Thanks for your answer, unfortunately I have no idea what I can do, maybe you can help me

I have no idea how to change the permission on Windows, I'm linux user, try to read this post https://answers.microsoft.com/en-us/windows/forum/windows_10-security-winpc/how-to-change-folder-and-file-permissions-in/783e7040-d18f-4c04-a0f3-830b4841bb68

This long standing issue should be fixed in https://github.com/bitcoin/bitcoin/pull/21907.


text:
How to track down OOM?
Since a while LND on m Bitcoin Node is restarting weekly a I get an OOM:
Feb 12 21:07:24 umbrel kernel: node invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0

Feb 12 21:07:25 umbrel kernel: oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=fd6a4e7d7c051ba13160a8ccbfb06cbc318d6529dab17e259804899aa073d11a,mems_allowed=0,global_oom,task_memcg=/,task=lnd,pid=24810,uid=1000

How can I find out what is causing the problem?
Many thanks in advance for your help or any hint :-)

From the logs, it appears you are using Umbrel. This is likely an Umbrel-specific issue related to their custom OS. I'd suggest checking out https://github.com/getumbrel/umbrel and asking for support in their Telegram chat.

I would recommend not using umbrel as their support is really inconsistent and they are not a totally open-source product

Thanks @poseidon, well I'm aware of it but not quite ready to switch over yet to something better, was thinking of a an upgrade my RPi4  to Raspibolt or even build a new bare metal node and migrate over :-)

That's understandable, I personally have not deployed a Lightning Node since my umbrel suffered its series of horrible issues, thankfully I did not lost too many sats in that escapade but I certainly learned that diving into lightning was not super easy and 'safe' especially not opening tons of channels with barely known peers.

@deekee I setup a LND node recently. If you are even relatively comfortable with Linux command line that should be a breeze for you. Will also teach you the basics of lightning from a developer level. Next to impossible to know why Umbrel would be doing something from my point of view. LND is much easier to debug. Also OOM generally suggests you have many processes running on a low memory device. Increasing the amount of ram can potentially help or closing background applications that arent being used on the device.


text:
What prevents a miner to change the locking scripts of an unconfirmed transaction
In many cryptocurrencies a TX is composed of an array of TX inputs and TX outputs.
When a TX is submitted to the network, it already has the signature (in the unlocking script).
So my question is, what does prevent a miner or anyone on the network to use the already present unlocking and change the locking scripts of the transactions and then propagate the transaction.
Because in my understanding I may provide a signature to unlock a txo and someone uses my signature to change the locking scripts of those TXs.

Signatures cover inputs and outputs.
If someone changes one of the outputs in a transaction, a new signature is required. Effectively your signature signs "permit using my UTXO X to send A BTC to B, C BTC to D, ...".

Then my question is what is really signed in a bitcoin unlocking script. I was doing some research on the bitcoin script.  And for a P2PKH TX,  the stack pre final state is a pubkey,  a signature and OP_CHECKVERIFY, No mention of which data was signed or to be verified.

The search term for that is the "sighash". It's a hash of a (modified version of) the spending transaction. It's modified because the signature would need to sign itself if it was included. BIP143 changes the sighash scheme.

But conceptually, you can say that most signatures effectively sign the entire spending transaction.

"But conceptually, you can say that most signatures effectively sign the entire spending transaction”      Does that mean the signed data is the SHA 256 (TXOs) ? If so we might have a transaction with identical TXOs which might end up giving the same message digest.

What does TXO stand for? You can say that what is signed is the entire transaction (all inputs, all outputs), excluding the signatures themselves.

I have just got to understand what really happens. Nevertheless Blockchains are currently poorly documented. I'm really thankful for the time you dedicate in explaining these technologies.

Here is a specification for the signature hashing scheme used in witness v0 spends: https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#Specification

Because in my understanding I may provide a signature to unlock a txo
  and someone uses my signature to change the locking scripts of those
  TXs.

Taking a "P2PKH tx", the unlockscript requires some operations to be executed while spending a tx:
<sig><pubkey><OP_DUP><OP_HASH160>pk hash<OP_EQUALVERIFY><OP_CHECKSIG>

I have three scenarios here, when changing parts of the script fields:
1.) change <sig> and <pubkey>
a miner changes the  part with a new signature and pubkey. Assuming the block raelly gets "through", the spender of the funds has a problem, cause his  would not match to the hash of the  anymore.
2.) change only the <sig>
a miner changes only the  part with a new signature. Now the spender's  would match the hash of the . However the last command <OP_CHECKSIG> would check the remaining parts on the stack (<new sig><pubkey>), and this would (obviously) fail.
3.) change the pubkey script
when anything in the pubkey script is changed, then the signature process will fail. During creat
ion of the signed transaction, the sigscipt area is filled with the pubkey script, and then signe
d. Later on, before transmitting the tx, the sciptsig area is replaced with <signature><pubkey>.
So when the block would be propagated to other nodes, they would verify this block and it's tx in
side, and discover a signature mismatch.
Pieter explained details here of the scriptsig here:
What are the parts of a Bitcoin Transaction "Input" script?
and two references that further help to understand:
1) http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html
2) Andreas' book "Mastering Bitcoin", 2nd Edition, page 135ff


text:
After using openassets issue_asset() , the asset quantity is 0
I am using openassets protocol issue_asset() function. After using the function, i call list_unspent(). The asset quantity field is all zero (see below). It means the issue_asset() function does not generate any assets. I have checked the return value of issue_asset(). It returns a valid transaction. Is there a reason why assets are not created?
The list_unspent() output is copied below:

[{"txid"=>"39e2b19597c5ab2e9d88ed7323a63a6de418dc3f04597ba5c520c5b968963b0e", "vout"=>0, "confirmations"=>119, "address"=>"mv3JUS2pmGj7QMXEtrpz4xtt3QuZdaqdE6", "oa_address"=>"bX61BibrAEkcoGbgbwUwAipoTP25jejEPFV", "script"=>"76a9149f4f15984e7ecbde4a14ace89d564d366fa206b788ac", "script_type"=>"pubkeyhash", "amount"=>"0.00000000", "asset_id"=>nil, "asset_quantity"=>"0", "asset_amount"=>"0", "account"=>"", "asset_definition_url"=>"", "proof_of_authenticity"=>false, "output_type"=>"uncolored", "solvable"=>true, "spendable"=>true},
{"txid"=>"6179fd02c7a031711d654068ef365e8d50c1aea57fc4a5554ca31de01bc47931", "vout"=>0, "confirmations"=>117, "address"=>"mv3JUS2pmGj7QMXEtrpz4xtt3QuZdaqdE6", "oa_address"=>"bX61BibrAEkcoGbgbwUwAipoTP25jejEPFV", "script"=>"76a9149f4f15984e7ecbde4a14ace89d564d366fa206b788ac", "script_type"=>"pubkeyhash", "amount"=>"0.00000000", "asset_id"=>nil, "asset_quantity"=>"0", "asset_amount"=>"0", "account"=>"", "asset_definition_url"=>"", "proof_of_authenticity"=>false, "output_type"=>"uncolored", "solvable"=>true, "spendable"=>true},
......
{"txid"=>"fe1920a5f71566e9ea1c5a61d0d818d64816170992df27b445003fba2a730fe8", "vout"=>0, "confirmations"=>114, "address"=>"mv3JUS2pmGj7QMXEtrpz4xtt3QuZdaqdE6", "oa_address"=>"bX61BibrAEkcoGbgbwUwAipoTP25jejEPFV", "script"=>"76a9149f4f15984e7ecbde4a14ace89d564d366fa206b788ac", "script_type"=>"pubkeyhash", "amount"=>"0.00000000", "asset_id"=>nil, "asset_quantity"=>"0", "asset_amount"=>"0", "account"=>"", "asset_definition_url"=>"", "proof_of_authenticity"=>false, "output_type"=>"uncolored", "solvable"=>true, "spendable"=>true}]

I also called get_balance(). The output is listed below. The is no assets too.

Balance [{"address"=>"n3hqP9u5kQydyqGcPy3NHcEWnzBKJnv3aX", "oa_address"=>"bXDfidKiRDtsKr5RySb9YwU968bMVMnf8Zr", "value"=>"0.00433888", "assets"=>[], "account"=>""}]

The problem is after issue_asset(), if the min_confirmation is 1, we have to mine the bitcoin block for one time. Then only after that, the asset can be seen in get_balance.


text:
Explorer for blockchain
I want to develop an explorer for coins(BTC,LTC,BCH,...), like blockchair, or blockchain. I've searched a lot and I have found different answers. Finally, here is my solution. First, I use RPC to retrieve all blockchain data and insert them in a Mongo database. After retrieving all blocks data, I use the ZMQ feature of the core, to retrieve realtime blocks and transactions. Transactions will be saved in a separate (in memory) table which is the mempool table. Whenever a new block is found, I delete the mempool transactions which exists in the new block. I have some problems. The first problem is in finding UTXOs of addresses. The utxo query is complicated and takes a long time to respond(I've indexed the fields that uses in utxo query). My solution for this problem is preprocessing data before inserting them in DB and mark the spent outputs. There are other solutions too. One of them is parsing chinstate/levelDB files and extracting utxos. Should I change the schema of the DB for performance? I am confused. The second problem is mempool transactions. They will be lost when I reset the core(for mainteneance). So I lose the unconfirmed transactions. How should I handle them? I don't know whether my solutions are optimal or not? Any suggestions for solving the mentioned problem?
My MongoDB has two collections: blocks and transactions.


text:
What is the reason for not transferring Bitcoin to the wallet?
Yesterday I made a payment in the amount of 0.2 bitcoins but it didn't arrive in my wallet account, what should I do?

It would be helpful if you can provide some more details. Can you update your question with the wallet you are using, where you were sending the funds from, and the transaction id?

I collected 0.2 bitcoins on the btc free.cc website and withdrew this money with the Transt wallet, but it still hasn't arrived in my wallet. It says pending payment.
When will it count? Will it really be deposited in my wallet???

Yes. I collected this amount. For what?

Those websites are fakes and anyone directing you to them is scamming you. Bitcoin is completely based on personal choice there will basically never be a situation in which you randomly receive bitcoin for free. Especially not these days. If an exchange you are using offers you free coins as a promotion that is different but this is clearly not connected to anything you are seriously familiar with therefore it is clearly a scam.

Some time ago, I transferred the amount of 0.2 bitcoins that was collected from your site to my wallet, now it is waiting and it has not arrived in my wallet (name of my wallet: trust wallet)
If you please and follow up, I will thank you

What is the reason for not transferring Bitcoin to the wallet?

You should ask the person who is not transferring the money.
One possible reason might be that you are dealing with criminals who are confidence tricksters (conmen) who are running a scam. Perhaps the website is fraudulent or is being used as part of a scam.

I collected 0.2 bitcoins on the btc free.cc website ...

A wise man once wrote "there ain't no such thing as a free lunch" (TANSTAAFL).

... and withdrew this money with the Transt wallet,

Maybe one or more of the following applies

no one really sent any money.
it's a fake wallet.
the wallet isn't fully synchronised yet.


text:
Can I delete blk*.dat files?
Since bitcoin validates blockchain by the hash of older blocks recursively; Can I just keep the last blk*.dat file and delete the rest while the bitcoin core is downloading and validating the blockchain?

No, if you manually delete these files, Bitcoin Core will notice the missing files and abort.
However, Bitcoin Core does have functionality to discard blocks after validating them: pruning. You can enable pruning by setting prune=<n> in your bitcoin.conf file or by passing -prune=<n> to bitcoind on startup.
Check bitcoind -h for more information, but briefly:

prune=1 allows for manually deleting blocks using the pruneblockchain rpc
prune=<some number >= 550> enables your node to automatically delete blocks to keep the size, measured in MiB, less than the number specified

A few things to keep in mind when pruning:

You cannot run txindex while pruning, so you won't be able to use your node to lookup specific transactions
If you ever want to turn pruning off, you will need to re-download the entire blockchain

And to be clear: no, you can't just delete the files manually. Bitcoin Core will notice the files are missing and abort.


text:
Building neutrino from source for use with lnd
I am trying to build neutrino, to use with lnd.
However I cannot find any installation instructions.
Someone else also asked for install instructions a few months ago and got no reply.
I have installed go version go1.19 linux/amd64.
Even though I am not familiar with go, I am trying to guess the steps.
This is what I tried first:
git clone https://github.com/lightninglabs/neutrino
cd neutrino
git checkout v0.15.0
make clean
make

This is the output from make:
 Compiling neutrino.
 go build -v github.com/lightninglabs/neutrino/...

I can't find any binaries after doing this.
Then, I tried the following:
 go build -v -o ~/neutrino *.go

This created an ar archive which is not executable:
 $ file ~/neutrino
 /home/alexg/neutrino: current ar archive

Obviously I am doing something wrong.
Why can't I find the installation instructions? Can someone help?

From what I can tell, neutrino is not a standalone node but a library that lnd uses to be able to run in "neutrino" mode.
To use lnd with a neutrino backend, compile lnd from the source and then run with the following options:
 lnd --bitcoin.active --bitcoin.testnet --debuglevel=debug \
       --bitcoin.node=neutrino --neutrino.connect=faucet.lightning.community

(Taken from https://github.com/lightningnetwork/lnd/blob/master/docs/INSTALL.md#using-neutrino)
This issue also mentions that you may need to compile LND with experimental flags in order to use neutrino, although I am unsure if this is still the case.

I feel very dumb now. I was 100% sure that it was some stand-alone daemon. Thank you!


text:
given a json of a block, how do I calculate its hash?
Here is the genesis block with its hash. How the hash was calculated?
{
  "hash":"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
  "ver":1,
  "prev_block":"0000000000000000000000000000000000000000000000000000000000000000",
  "mrkl_root":"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
  "time":1231006505,
  "bits":486604799,
  "nonce":2083236893,
  "n_tx":1,
  "size":285,
  "tx":[
    {
      "hash":"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
      "ver":1,
      "vin_sz":1,
      "vout_sz":1,
      "lock_time":0,
      "size":204,
      "in":[
        {
          "prev_out":{
            "hash":"0000000000000000000000000000000000000000000000000000000000000000",
            "n":4294967295
          },
          "coinbase":"04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73"
        }
      ],
      "out":[
        {
          "value":"50.00000000",
          "scriptPubKey":"04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f OP_CHECKSIG"
        }
      ]
    }
  ],
  "mrkl_tree":[
    "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"
  ]
}

As described on the wiki page about block hashing, the 2xSHA256 hash is taken of the block's header only (not the transactions in it): 80 bytes, consisting of the version, previous block hash, tx merkle root, time, bits and nonce.
Direct quote from that page :
>>> import hashlib
>>> header_hex = ("01000000" +
  "81cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000" +
  "e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122b" +
  "c7f5d74d" +
  "f2b9441a" +
   "42a14695")
>>> header_bin = header_hex.decode('hex')
>>> hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest()
>>> hash.encode('hex_codec')
'1dbd981fe6985776b644b173a4d0385ddc1aa2a829688d1e0000000000000000'
>>> hash[::-1].encode('hex_codec')
'00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d'


text:
Adding an external key pair to a local bitcoinj wallet
I need to add a vanity address to a local wallet that I maintain using bitcoinj APIs. I'm not able to search for the vanity using bitcoinj APIs directly, on my local PC, because my vanity is too fancy. However, I'm able to generate the pair online easily. What is the API I should use to add this key pair to my local wallet ?
I tried the following,
Say the required vanity is 1meowvYmB7ughhsRvUWfsac9LKDonh4cn (private key: 5JXFsJEAiqtTv95rSmw3KSJeAZ97SsmKWTQq5yqBzioSJ1guUHK). I generated this at bitcoinvanitygen, I converted this to hex at, Base58 Encode, Decode, and Validate. I tried the following.
Address vanity = new Address(networkParameters, networkParameters.getAddressHeader(), Hex.decode("000871DD31D517D15D7352139A44B07EBE97B1772C7F291357"));

I need to construct an Address from this string. I get the following error:
exception decoding Hex string: String index out of range: 47

Note: generating private keys online is very risky! Doing so may leave your funds at risk.

After searching for a while I found this type that takes a private key (in base58), required network parameters, and constructs the public address. Please refer: DumpedPrivateKey. This was enough for me at least. I construct an address from the key so formed using the toAddress method exported from the type key.
DumpedPrivateKey vanityKey = DumpedPrivateKey.fromBase58(networkParameters, "5JXFsJEAiqtTv95rSmw3KSJeAZ97SsmKWTQq5yqBzioSJ1guUHK");
ECKey ECVanityKey = vanityKey.getKey();
Address vanityAddress = ECVanityKey.toAddress(networkParameters);

At first the 'Service' you used is a common scam their are not providing splitkey generation this means, the private key you got is saved by them! Dont use this address. Use only vanity address Services with splitkeys by give it your Public key, then you got a vanity address and a partial private key, if you merge the splitkeys (privatekey of the given pubkey and partial privkey) to get the final private key!
Import the private key just by open your wallet for example Bluewallet or electrum and import the final priv key!
Ps: please delete the backlink to this scam read in bitcointalk about this!


text:
Ardor Conversational Wallet
Any idea what it would take to build a conversational wallet for basic interactions with Ardor accounts through a chat bot and what the potential risks are?
Will also appreciate any possible code repo dealing with this.
Thanks.
CryptAIVR

The main challenge is how to secure user passphrases.
In the past we had a slack bot implemented in C# https://github.com/libertyswede/NxtTipbot you can use it as reference implementation.


text:
Why lightweight nodes are less secure?
as you know there is two main type of wallets:
full node and
light node
I've read in some advice that just using full node for more security stuff
and the next question is what is the type of blockchain.com wallet?
many thnx :kiss:

Why lightweight nodes are less secure?

A lightweight node is less secure because it doesn't store its own copy of the entire blockchain.
This means it cannot verify for itself the integrity of incoming blocks with complete certainty. It generally has to rely on the integrity of an external server for at least some starting block. This is the kind of trust of third parties that Satoshi Nakamoto was trying to avoid when creating Bitcoin.

and the next question is

One question per question. Please use the "Ask Question" button at top right to ask a new question. You can include a link back to this question if it helps clarify your next question.


text:
Xpub for HD wallets
I have a cold storage in my one of the computers.Also in my project server I have run bitcoin-cli. So I want to remove priv key from here and set the public key from cold storage. I read that it will more secure and I can spend my coins only from cold storage. How can I implement this mechanism ?
Thanks!

You can't do this with bitcoin core since it uses hardened derivation so you can't derive addresses using the extended public key. You should use electrum for this instead. An electrum watch-only wallet can mirror the addresses of a an electrum seeded wallet. So just create an electrum wallet on your desktop as normal and then grab the master public key aka extended public key via wallet menu > information. You can then derive addresses using that. The easiest way would be to install electrum on the server, restore the wallet using the xpub:
electrum restore xpub...
Then you can use the addrequest command with the --force switch to generate addresses:
electrum addrequest --force 0.1
The JSON code that is output will contain a unique address everytime. Note you may have to increase the gap limit on the seeded wallet on your desktop via wallet.change_gap_limit(200) on the console tab (view > show console).
Electrum also has a JSON RPC interface as well but you will have to research how to use that yourself.

thanks for reply. So I have run the following commands, and at first I have created an account called default_wallet. than when I have run electrum addrequest --force 0.1 it maybe creates an address and I got the follwing  response
    "URI": "bitcoin:12RDcyE2YRFy6d9NcMhPE2ABszaqMqqqrG?amount=0.1",
    "address": "12RDcyE2YRFy6d9NcMhPE2ABszaqMqqqrG",
    "amount": 10000000,
    "amount (BTC)": "0.1",
    "exp": null,
    "id": "e2471abf54",
    "memo": "",
    "status": "Unknown",
    "time": 1539202269
}```

I want to know where did amount come from? and what is the amount ?

The addrequest command requires that you provide it an amount. However that amount is meaningless so just enter anything you like. The amount is the 0.1 part of the command i gave above.

Is there a fullnode for BitcoinCash that supports xpub?