text:
What's going on with address 1NZ9kxxUykiNSe61ZRNPLqWeVHVRnirGry?
Does anyone know what is going on here:
https://blockchain.info/address/1NZ9kxxUykiNSe61ZRNPLqWeVHVRnirGry
As far as I can tell, it looks like the "1NZ9..." address seems to be one one of those which "cannot be decoded"? How did blockchain.info then decide to show this information page on the address? Because, If I do a getrawtransaction on the tx shown there, I get no addresses from bitcoind.
And if the address is one of the "cannot be decoded" ones, how come the Total Received and Final Balance fields are 0?

What is happening here is that blockchain.info parser seems not to work well when decoding Pay-to-multisig scripts (P2MS).
All the outputs but last two contain Pay-to-multisig scripts as ScriptPubKey (1-3 Multisig for all but the very last one, that is 1-2 Multisig). The last two are normal Pay-to-PubkeyHash (P2PKH).
If you check the information in blockr.io for example, you will see it correctly displayed.
You can also check the decoded raw transaction to find it out. Here you have an example of one of the outputs:
"asm":"1 8322e509a68669409750b06abef89e48423d21c0089efcc211261c16e8f0a413a693bdee97ca3bd3424eb6247bc235a8d49d77cde681093a4824e462a9ea9610ed b72f5174d4946b456da718db0eb1e852a67544c67e6041f1eb6156bae1b1d788614d89542274f46f0100389a6b40f5158dab5da9870b3447b65e8d003665d0e969 db99614d616506661872851a2786ec296ca73dbab8dbf100c21ef2e80be79eb5d916ab3b3b29ec6e5dcda45a405c155655fe380d979877e53b2f1417a744ebf142 3 OP_CHECKMULTISIG"

Notice how the structure of the script is: OP_1 <Public_Key0><Public_Key1>...<Public_KeyN-1> OP_3 OP_CHECK_MULTISIG

Ok, that makes sense, thanks! Is there a way to get to the list of addresses using bitcoind RPC?

What do you mean by the list of addresses?

The result of getrawtransaction for this type of tx includes (in the outputs array) the bitcoin amount but not the output address.

Sorry, I've been out a few days. This also depends on the decoder you are using to analyse the raw transaction you get from getrawtransaction. For example, blockchain.info (https://blockchain.info/decode-tx), or blockr.io (https://blockr.io/tx/push) do not provide the information about addresses in P2MS transaction, you can only see the collection of public keys inside the script. However, blockcypher (https://live.blockcypher.com/bcy/decodetx/) does.


text:
Is MEV possible on bitcoin?
Miner Extractable Value (MEV) is a big topic in the life of Ethereum users, and it creates an additional revenue source for the miners.
Is MEV possible on the Bitcoin blockchain as well? And if yes/no, why and is it being used?

In Bitcoin, transactions generally¹ have immutable self-contained outcomes—they boil down to a list of inputs spending existing UTXOs, and a list of outputs to be created. All the amounts involved are independent from the position in the block, or even what block a transaction gets into.
In Ethereum, especially transactions interacting with more complex smartcontracts, some of the values of transactions are dynamic. If you e.g. place a market order on a decentralized exchange, you may get more or less for your money depending on whether other transactions call the same contract before you. Since miners see transactions before they are confirmed, they can front-run such transactions. This is how they can extract value by reordering transactions.

¹ Arguably, miners could hypothetically benefit in scenarios where there are multiple transactions with competing outcomes, e.g. the closing of a Lightning channel. In some such situations, a miner could perhaps benefit from not including a transaction in their block or doing something else than picking the transaction with the highest feerate. This could potentially lead to some form of MEV on Bitcoin, but if the incentives of such second-layer protocols are properly designed, I would expect them to remain negligible exceptions.

In the case of Ethereum, when front running happens, do the miner utilising MEV orders his/her transaction before the other's as he/she is the one who mines the next block, or he is just able to analyse the mempool and can set higher fees to his/her order and the ordering happens automatically?

No, in Bitcoin most miners simply choose the transactions with the highest fees.
The order of transactions just has to be valid (eg, transaction that spends a UTXO of another transaction in the same block has to be placed after the transaction it spends). As long as it is any valid order, which particular order is not particularly important.

Why is this different in ethereum? Why can they extract value there by reordering and not here?

source: Stack Exchange

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

sort: votes


text:
Public key factors - but what's next?
Let's say I found (I know, impossible) public key factors. What to do with them next to compute original private key for that public key?

Let's say I found (I know, impossible) public key factors.

Bitcoin public keys are coordinates of points on the secp256k1 elliptic curve. They are not integers, and thus factoring is not an operation that applies to them.

What to do with them next to compute original private key for that public key?

Bitcoin's (ECDSA) security is based on the hardness of computing the discrete logarithm of points on the secp256k1 curve, not on the difficulty of factoring large integers (like e.g. the RSA algorithm is). Having access to a fast integer factorization algorithm will not in any way help you compute private keys of Bitcoin public keys quickly.

Can you say what to do, not what is impossible?

There is nothing to do. Factorization is just entirely unrelated to Bitcoin's security. This isn't a question of "hard" or "impossible"; the word "factorization" just has no meaning w.r.t. Bitcoin public keys.

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


text:
How to use python rpc bitcoin to get the historical transaction record of a wallet address
How to use python rpc bitcoin to get the historical transaction record of a wallet address？My computer has synchronized all btc blocks, and txindex=1 has been configured. I want to try to get all the historical transaction records of a wallet address. Do I still need to create a mysql or redis cache? Below is my configuration
datadir=/opt/bitcoin/bitcoin-data
dbcache=10240
txindex=1
rpcuser=*****hi
rpcpassword=****
daemon=1
server=1
rest=1
rpcbind=0.0.0.0:8332
rpcallowip=0.0.0.0/0
deprecatedrpc=accounts

I just want to input an address and connect to the local BITCOIN RPC to query all historical transaction records of a specific address
An empty message was returned
root@ubuntu:~# bitcoin-cli listtransactions  "3Fr1mGhnPAQ9YDf1dzg4B47PkX5TuvFtYv"
[
]

Bitcoin-core does not keep an index of address balances or histories. You will need to find/write some additional code in order to use it in this way.

As @hamita pointed out you need to set server=1 in your bitcoin.conf file then you can use python-bitcoinrpc library to communicate with your bitcoin node.
Here's a short script to get all transactions of an address:
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from pprint import pprint

# rpc_user and rpc_password are set in the bitcoin.conf file
rpc_user = "<from bitcoin.conf>"
rpc_pass = "<from bitcoin.conf>"
rpc_host = "<ip address of your bitcoind>" # if running locally then 127.0.0.1
rpc_client = AuthServiceProxy(f"http://{rpc_user}:{rpc_pass}@{rpc_host}:8332", timeout=240)

track_address = "<your address>"
tx_list = rpc_client.listtransactions()

address_tx_list = []
for tx in tx_list:
    if tx['address'] == track_address:
        address_tx_list.append(tx)

pprint(address_tx_list)

I'm also writing the chapter Accessing Bitcoind with Python if you want to know more. NOTE: It is a work in progress.
EDIT: Added server=1 for completeness.

I just want to input an address and connect to the local BITCOIN RPC to query all historical transaction records of a specific address,I can't query all historical transaction records by trying this code, is there any good idea? thank

An empty message was returned root@ubuntu:~# bitcoin-cli listtransactions  "3Fr1mGhnPAQ9YDf1dzg4B47PkX5TuvFtYv"
[
]

That is because that address is not being tracked by your node as it wasn't generated by it nor it isn't watching the wallet that generated that address. If you want to be able to track each and every address then you should use something like esplora which is what blockstream.info backed is.

To communicate with your bitcoin core, you must change your bitcoin.conf and set
server=1
Then connect to your bitcoin core with "http://user:password@127.0.0.1:8332"

This page will help you to config your node. https://jlopp.github.io/bitcoin-core-config-generator/

I have configured this parameter server=1, but executing bitcoin-cli listtransactions 1JXKXFuB4HZf18JnpKADe2R3J8taoCcQEE still returns empty

@user51679 Edit those in your conf file rpcallowip=127.0.0.1
rpcport=8332

The address I monitor is any address, is there any difference between this and 127.0.0.1 monitoring? Affect the query?


text:
Can brand new hardware wallet have seed phrase initiated via sparrow? Or do is it need to be through wallet OEMs site only?
Pretty straightforward. Can I initialize/generate seed phrase of blockstream jade via sparrow? Or do I need to go through blockstream's site to do this?


text:
Is the Bisq API finally "live" now or what?
For many years now, I've been waiting for Bisq to implement its damn API so I can begin trading (between crypto currencies, since automation is impossible with fiat).
Today, I again did a "round" to check if it has happened, and... I'm not sure? There are numerous old posts about the different APIs, and recent mentions of it, and there's this cryptic "documentation": https://mrosseel.github.io/bisq-api-examples/
But is it actually "live"? Can I start automatically trading with it today? Or is this still in some kind of "test-only" mode?
I would have asked them directly if it weren't for the fact that every single channel they provide to communicate with them refuses registration or requires weird software to be installed.

More information: https://helloreverb.com

It's probably not a good sign that this shows some kind of generic "under construction" message...
I've browsed their official website for a long time without finding any mention of the API, so I assume that it's not live?

A Bisq gRPC API was publicly announced with the Bisq v1.9.1 release:
https://github.com/bisq-network/bisq/releases/tag/v1.9.1
Here is the gRPC API Reference (with CLI, Java, and Python examples):
https://bisq-network.github.io/slate
Those API examples are versioned at https://github.com/bisq-network/bisq-api-reference, and the project is a decent place to develop Bisq gRPC API bots.
Here is an interesting post about creating a Bisq gRPC API client or bot with Rust:
https://www.alexsears.com/2022/05/bisq-api-rust-project-setup
A related twitter account was created in May 2022:
https://twitter.com/bisq_v1_api


text:
Are there CoinSwap-like protocols that don't need access to raw private keys?
Say you would like to atomically swap Bitcoins with a counterparty, without an obvious on-chain link such as a hash pre-image used in an HTLC-like Bitcoin Script.
The constructions I am aware of proceed to fund two 2-of-2 multisig outputs that will later be claimed by the respective counterparty, with some magic to make the claiming of the two outputs atomic.
A common property of such constructions is that they need "deep" access to the private keys involved:

In the case of CoinSwap, the private keys are exchanged between counterparties (in the privacy-preserving case where the hash pre-image never hits the blockchain)

In the case of Adaptor Signatures, access to the raw private keys is also necessary to compute the adaptor signature offsets (s = s' - t in the linked document)

Are there any similar protocols that can work if the private keys are inaccessible and only the public keys and signatures over provided messages are available, think a hardware wallet?
In the case of asymmetric protocols, it would already be interesting if only one of the two parties needs access to raw private keys.

From what it sounds like you are asking for a protocol that doesn't require the output to be locked to a key specific to the (current) protocol users (so it is locked to a proof that has no concept of a third or secret shared key at least).
I believe the reason this does not exist comes down to a few factors:

It would force the UTXO to be locked to a preimage in which anyone who knows could spend, instead of this being locked to a preimage in which only the receiving public key (who has learned the new preimage) can spend. (atomic double-spend attack vector, can be 'swapped' with anyone at the same time)
It would force the hardware wallet user to use private key data from their real private key instead of a temporary one which is generally used for the atomic swaps (like coinswap). This means if the protocol they use is insecure they could leak their real private key. (maybe a bit of a stretch I guess)
Secret sharing is how the atomicity is preserved. If there is no secret to be shared from my perspective there is no way for a party to convince you that they cannot cheat. If they remain in control of the secret knowledge and require you to spend with just one proof of that secret, it is highly possible for them to generate more valid proofs which could then be used to spend regardless if you have one valid signature for it.

You need an extra DL that is specific to the current swap or else such a signature could be reused by anyone knowing their own keys. If, for example, you reuse the same DL for two different swaps you open up tons of double spend vectors to your counter-parties as soon as they see the same proof hit the blockchain again.
Another note: your hardware wallet does not necessarily need to hold on to these keys at any point it really just needs to sign a transaction that proves one of the keys. Generally all of the transaction metadata is not held on the HW anyway, so in this case the extra private key is just transaction metadata in some sense.


text:
btcchina how to deposit with mastercard?
https://vip.btcchina.com
I'm trying to "Fund CNY" to use in my bitcoin trades.
The problem is, whichever bank I choose, it redirects to a login page asking for a password or mobile payment option which I don't know how to use.
I only have the mastercard payment option. How can I fund?

you need to make a wire transfer to a china bank or fund your account with bitcoins

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


text:
Is the following a valid bitcoin private key? - FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE
In secp256k1 (Bitcoin's elliptic curve) it is defined that valid private keys may range from 1 to FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141 - 1. (https://crypto.stackexchange.com/questions/30269/are-all-possible-ec-private-keys-valid)
However I created an EC Keypair with the private key being FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE imported it into bitcoin core and sent a small amount of btc to the corresponding bitcoin address. I was able to spend these coins. Does that mean that bitcoin does not follow this restriction and any combination of 256 bits is a valid private key for bitcoin? Or might it be a bug that could get fixed in future?
I'm currently myself deriving bitcoin private keys/addresses from a seed and importing them via json-rpc. I saw that implementations of e.g. BouncyCastle check whether an EC is in that forbidden range. I currently don't do that but I also think that even if bitcoin wouldn't accept such keys the probability of deriving a private key in that forbidden range is too low to justify the additional implementation complexity (at least in my case). Is that problematic?
Update -
Here's how I created the private key:
byte[] privKeyBytes = {1,1,1,1,1,1,1,1,...,1,1,1,0};
byte[] version = { (byte) 128 }
byte[] privateBytesPlusVersion = MyUtils.concatenateByteArrays(version, privKeyBytes);
byte[] versionPrivateAndCompressed = MyUtils.concatenateByteArrays(privateBytesPlusVersion,
            COMPRESS_BYTE);
byte[] checksum = getChecksum(versionPrivateAndCompressed);
byte[] versionPrivateCompressedAndChecksum = MyUtils.concatenateByteArrays(versionPrivateAndCompressed,
            checksum);
String privKeyDump = Base58.encode(versionPrivateCompressedAndChecksum);

The Base58 class is from BitcoinJ. I then imported this string via json-rpc with importprivkey
Update2 -
As Pieter Wuille pointed out I had an error as privKeyBytes {1,1,1,...,1} is not 'FFFFF...FFF'. I tried to import such a private key again and bitcoins rpc interface answered with an error: "Private key outside allowed range". I'm still tempted to not check for this range as the probability of me generating something with 120 1 bits at the beginning seems low enough to discard that case.

How did you create and import that private key?

Thing is the way it was imported may have considered it a little endian 256 bit number, that would lead to FEFFFFFF .... which is lower than the maximum.

@PieterWuille I updated my question with information about how I created/imported the private key

@Gopoi I see, but I think I also tried it with all FFFFs and it works. Will try it again tomorrow

Shouldn't privkeybytes be {255,255,255,...}?

@PieterWuille: Java byte is signed (two's-complement), so 255 is not permitted; -1 is, and (byte)255 is the same as -1 but in this context clearer. It is treated as unsigned in some contexts, including bitcoin and crypto, by masking with &0xFF.

why not to use byte[] privKeyBytes ={0xFF,0xFF,0xFF,0xFF,....,0x00}

The code you pasted is {1,1,1,1,...} not {-1,-1,-1,...}.

Can you share the address you generated?

@PieterWuille you're totally right and I'm quite sure I did not use {1,1,1,..,1} It was just temporary test code that I don't have anymore so I recalled from my memory. I'll right now play it through again and update my post

@PieterWuille alright, I tried it again and this time bitcoind answered with "Private key outside allowed range". So probably I also did that wrong the first time I tried it. Do you see a problem with me still not checking that case? When I maybe generate a couple thousand private keys a day it seems not really realistic to generate one with FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFF at the beginning

well.. I'm checking the range now anyway.

Accidentally hitting one of those numbers outside of the range is about as hard as solving the ECDLP problem (what you'd need to do if you wanted to steal coins with just the public key). That's only the case for secp256k1; other curves may have a ln order that's far further from a power of 2.

since the group is cyclic with order N, then this key will be equal to 0x14551231950b75fc4402da1732fc9bebd (your key modulo N)
>>> hex(N)
'0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141'
>>> y=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
>>> multiply(y)
(101611976893179986611445456504760352678020054910766426941542489291446644113297, 62728409327141118228093362610154100530630533850909349244575637074165425046447)
>>> y%N
432420386565659656852420866394968145597
>>> multiply(y%N)
(101611976893179986611445456504760352678020054910766426941542489291446644113297, 62728409327141118228093362610154100530630533850909349244575637074165425046447)
>>> hex(y%N)
'0x14551231950b75fc4402da1732fc9bebd'

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


text:
Two identical R value finding z value from two transaction
tx1
from the trans1 i got
Input Scripts
30450220262e481b6d8905b5adba67aff05eb8261501b0a9434c0b7f043d00cf8d23c91b022100bf82c0d212f30d3a0599e9b879516d762eaf5688ab83787cf470e99af5a6917101
046578188abe5aaf9f3d1809d972e87307493dfefa3a5b6c94c870e8f58743179678f059c6402d9806ccce5d0672dc171d962fe392f8ef77cc9827c3eb633966b4

R = 262e481b6d8905b5adba67aff05eb8261501b0a9434c0b7f043d00cf8d23c91b
S2 = bf82c0d212f30d3a0599e9b879516d762eaf5688ab83787cf470e99af5a69171
tx1 raw trans
01000000012eb64643254262722e33e72cb2ad67fecb6ae2fd812d2f2bff217458715e11a0000000008b4830450220262e481b6d8905b5adba67aff05eb8261501b0a9434c0b7f043d00cf8d23c91b022100bf82c0d212f30d3a0599e9b879516d762eaf5688ab83787cf470e99af5a691710141046578188abe5aaf9f3d1809d972e87307493dfefa3a5b6c94c870e8f58743179678f059c6402d9806ccce5d0672dc171d962fe392f8ef77cc9827c3eb633966b4ffffffff02a0252600000000001976a914cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d88aca0252600000000001976a91409a4cb092dc30da1354369fc78f482365ce2767a88ac00000000

calculating z2
replace the input with the corresponding output script
01000000012eb64643254262722e33e72cb2ad67fecb6ae2fd812d2f2bff217458715e11a0000000001976a91409a4cb092dc30da1354369fc78f482365ce2767a88acffffffff02a0252600000000001976a914cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d88aca0252600000000001976a91409a4cb092dc30da1354369fc78f482365ce2767a88ac0000000001000000

then do sha256(sha256(modified transaction))
Z2 = e2b8acb01c0ea6a2a1273fc9dbbe3cdd58c68afb54e240e1f51abcc652468204
tx2
from tx2
Input Scripts
30450220262e481b6d8905b5adba67aff05eb8261501b0a9434c0b7f043d00cf8d23c91b022100d45c9ef85bb65a2a5bb3cf862124188adfe5fb8d430bc4b0d1222b1704d10d1901
046578188abe5aaf9f3d1809d972e87307493dfefa3a5b6c94c870e8f58743179678f059c6402d9806ccce5d0672dc171d962fe392f8ef77cc9827c3eb633966b4

S1 = d45c9ef85bb65a2a5bb3cf862124188adfe5fb8d430bc4b0d1222b1704d10d19
tx2 raw trans
010000000180a2856a5a973b0953328a8b2bca142acc0c1a20b4b77ffe4a62aab8afcc1293010000008b4830450220262e481b6d8905b5adba67aff05eb8261501b0a9434c0b7f043d00cf8d23c91b022100d45c9ef85bb65a2a5bb3cf862124188adfe5fb8d430bc4b0d1222b1704d10d190141046578188abe5aaf9f3d1809d972e87307493dfefa3a5b6c94c870e8f58743179678f059c6402d9806ccce5d0672dc171d962fe392f8ef77cc9827c3eb633966b4ffffffff01a0252600000000001976a914cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d88ac00000000

calculating z1
replace the input with the corresponding output script
010000000180a2856a5a973b0953328a8b2bca142acc0c1a20b4b77ffe4a62aab8afcc1293010000001976a914cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d88acffffffff01a0252600000000001976a914cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d88ac0000000001000000

then do sha256(sha256(modified transaction))
I got Z1 = f62dab861eb451dad7cc74fa9f754e4d233b5fb80b1327fd623f5617e1f46d21
but the correct z1 value is
z1 = 66042ab1a1befe137de5328ff1d4b263604824fe33c739d3a80565afdd94b34d
what wrong in the calculation

calculating z1
replace the input with the corresponding output script

This is the step where you made a small mistake.
The UTXO that's being spent is from txid 9312ccafb8aa624afe7fb7b4201a0ccc2a14ca2b8b8a3253093b975a6a85a280 which contains two txouts. When you did the script replacement, you chose txout #0 (with a hash160 of cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d), but the tx being signed is spending txout #1 (with a hash160 of 09a4cb092dc30da1354369fc78f482365ce2767a).
Doing the replacement with the correct txout script results in this, which hashes to the z1 value you were expecting:
010000000180a2856a5a973b0953328a8b2bca142acc0c1a20b4b77ffe4a62aab8afcc1293010000001976a91409a4cb092dc30da1354369fc78f482365ce2767a88acffffffff01a0252600000000001976a914cf3aaf67c964d5c239f4cf2d9c2d2a7257d85b5d88ac0000000001000000

Christopher Gurnee thank you now i get correct output

@Prabur If this has completely answered your question, please consider Accepting it (and of course the same goes for any other answers). More info on Accepting answers can be found here: http://meta.stackexchange.com/questions/5234/


text:
How to build a transaction using bitcoinjs-lib
I'm trying to build a transaction using bitcoinjs-lib.
Here is my last transaction.
https://blockstream.info/api/tx/91feea5f5c7b67b3e56c0f5d23d6da3065855c23b4cc7dded8efd8ff8065500f
{
  "weight" : 705,
  "txid" : "91feea5f5c7b67b3e56c0f5d23d6da3065855c23b4cc7dded8efd8ff8065500f",
  "status" : {
    "block_height" : 795582,
    "block_hash" : "00000000000000000005386018b10cd1cde59d6923fd918757690c004b01c4b8",
    "confirmed" : true,
    "block_time" : 1687529469
  },
  "vin" : [
    {
      "inner_redeemscript_asm" : "OP_0 OP_PUSHBYTES_20 01868bd1fb92e6547438e8bf07a6c08ee0157c8b",
      "txid" : "e0c545a6dfaf1d5bb67f6349190d0653b597bda6585696cf217e55df07b1f190",
      "prevout" : {
        "scriptpubkey_type" : "p2sh",
        "scriptpubkey_address" : "3PA2J9aN9N82q4YZyhBYHBcHpVvpGewvX2",
        "value" : 956656,
        "scriptpubkey_asm" : "OP_HASH160 OP_PUSHBYTES_20 eb762ef1946c2d462764d30112ce27c531fdd603 OP_EQUAL",
        "scriptpubkey" : "a914eb762ef1946c2d462764d30112ce27c531fdd60387"
      },
      "scriptsig_asm" : "OP_PUSHBYTES_22 001401868bd1fb92e6547438e8bf07a6c08ee0157c8b",
      "is_coinbase" : false,
      "vout" : 1,
      "sequence" : 4294967295,
      "witness" : [
        "304402206000ff05c68afd2b2aece9554ef25bae6d7402be96c6eedc866f4ca1dcafe0dd02204dfc8852bd4c4ae2f36cd0f4db82d22e37422b08e7d829f10e5aa9d8ae07d70901",
        "02dba3c42f38c394dd7370884f23bd0dec5373e9d38439915124188f06b6a19395"
      ],
      "scriptsig" : "16001401868bd1fb92e6547438e8bf07a6c08ee0157c8b"
    }
  ],
  "vout" : [
    {
      "scriptpubkey_type" : "v1_p2tr",
      "scriptpubkey_address" : "bc1p7cqr7rhvxy8c69k5ks3qp6h3nq85tskgxd4f0h0mz5g3lvtykgtq4ddhyc",
      "value" : 54980,
      "scriptpubkey_asm" : "OP_PUSHNUM_1 OP_PUSHBYTES_32 f6003f0eec310f8d16d4b42200eaf1980f45c2c8336a97ddfb15111fb164b216",
      "scriptpubkey" : "5120f6003f0eec310f8d16d4b42200eaf1980f45c2c8336a97ddfb15111fb164b216"
    },
    {
      "scriptpubkey_type" : "p2sh",
      "scriptpubkey_address" : "3PA2J9aN9N82q4YZyhBYHBcHpVvpGewvX2",
      "value" : 894242,
      "scriptpubkey_asm" : "OP_HASH160 OP_PUSHBYTES_20 eb762ef1946c2d462764d30112ce27c531fdd603 OP_EQUAL",
      "scriptpubkey" : "a914eb762ef1946c2d462764d30112ce27c531fdd60387"
    }
  ],
  "size" : 258,
  "locktime" : 0,
  "version" : 2,
  "fee" : 7434
}

Here is the code I'm working on. What do I use for the redeem script?
const network = bitcoin.networks.bitcoin;
const psbt = new bitcoin.Psbt({ network });

psbt.addInput({
    hash: "91feea5f5c7b67b3e56c0f5d23d6da3065855c23b4cc7dded8efd8ff8065500f",
    index: 1,
    witnessUtxo: {
        script: Buffer.from("a914eb762ef1946c2d462764d30112ce27c531fdd60387", 'hex'),
        value: 894242,
    },
    redeemScript: Buffer.from("???", 'hex'),
});

psbt.addOutput({
    address: to_address,
    value: Math.floor(amount * 1e8),
});

psbt.signInput(0, keyPair);
psbt.finalizeInput(0);
const tx = psbt.extractTransaction();
return tx.toHex();

In P2SH, the output script is created by applying HASH160 (SHA256+RIPEMD160) to the redeem script, which is then revealed at spend time. So if you created the previous output, you should know what the script was.
However, since the address 3PA2J9aN9N82q4YZyhBYHBcHpVvpGewvX2 has already been spent from before, we can look at the blockchain and see the script is
OP_0
OP_PUSHBYTES_20 01868bd1fb92e6547438e8bf07a6c08ee0157c8b

or 001401868bd1fb92e6547438e8bf07a6c08ee0157c8b in hexadecimal form.
Your code should therefore be:
psbt.addInput({
    hash: "91feea5f5c7b67b3e56c0f5d23d6da3065855c23b4cc7dded8efd8ff8065500f",
    index: 1,
    witnessUtxo: {
        script: Buffer.from("a914eb762ef1946c2d462764d30112ce27c531fdd60387", 'hex'),
        value: 894242,
    },
    redeemScript: Buffer.from("001401868bd1fb92e6547438e8bf07a6c08ee0157c8b", 'hex'),
});

Is there a good tutorial where I can better understand this process? I'm having the same problem with another transaction and I'm not understanding how to resolve it.


text:
Transferred coin from Ledger Live to Sparrow
I transferred my bitcoins from Ledger Live Wallet to Cold Card. When I launch Sparrow, it shows the spent amount from ledger live and the coins received to their respective addresses. Is it expected to show the amount transferred from ledger live as a spent amount?
I dont find the interface of Sparrow as good as Ledger Live

Could you tell us a bit more about your setup? How was the Ledger connected to Sparrow? How does the Cold Card fit into your setup? What did you expect to happen?

I’m using cold card for the first time using sparrow. I used the receive address and put that into my send window while transferring in ledger live

Are your Ledger and Cold Card both holding the keys for the same wallet? I.e. did you import the same seedphrase in each?

I did not import the same seed. I have a new seed with my coldcard and I transferred my coins to the recieve address paying a new network fee

?can someone please respond to my post

The question isn't clear to me. For example when you write "is it expected to show the amount " what does "it" refer to? Are you using Sparrow as a front end to Ledger, to Cold Card or to both?

I transferred the coin from my ledger live wallet to my new cold card. It shows I received the coins but then there is a transaction which shows spent that appears to be a ledger live transaction. Is that sent transaction expected to appear to sparrow as well. I thought it’s a separate wallet so  wasn’t sure how it synced to show that as well

After receiving the coins on a coldcard, it appears the coins were sent to two new addresses in the blockchain. Is that expected?

The coins were recieved on the recieve addresses. After 2 hours or so, someone within the blockchain system picked up the coins and sent that to a new address. Is that normal ?

The coins were recieved on the recieve addresses. After 2 hours or so, someone within the blockchain system picked up the coins and sent that to a new address. Is that normal ?

No, that is not normal.

I checked and looks like within blockchain it was sent to a change address because my wallet was new. Not sure if there is a way to disable this in coldcard


text:
Is atomic swap flawed?
I'm reading this paper on atomic swap between BTC and XMR: https://arxiv.org/pdf/2101.12332.pdf and wonder if atomic swap with BTC is flawed by design.
My understanding is that, if Alice locks up XMR with a secret key s_a, she can then move the BTC Bob locked up after he broadcasts an adaptor signature by  combining it with s_a. However, what if Alice's XMR wasn't locked with s_a but with another key? Bob would still broadcast the same adaptor signature and Alice could still move the BTC to her wallet. Bob can't spend the XMR and will be funded back to Alice.
Am I missing something?

It is a prerequisite for atomic swaps that funds must be staged in outputs under shared control of both trading parties in both networks. This is achieved with a output script construction that has two spending conditions, where one spending condition requires both parties to sign off and the other spending condition allows the original owner to reclaim the funds in case the swap fails after a timeout.
The atomic swap protocol is insecure if one retains sole control of the staged funds. That would allow that party to divert those funds back to themselves once the other side has sent their funds.
On networks without on-chain multisig primitives, shared custody can be achieved through MPC.


text:
P2WSH Bitcoin Core Witness Script Empty Error
I am trying to spend a P2WSH output. Here are the steps I have taken:

I have created a P2WSH output via bitcoin-cli. These are the details of the P2WSH output:

Type
V0_P2WSH
scriptPubKey (asm)
OP_0 OP_PUSHBYTES_32 a2b95877500eb4180401640c5649c55ce578584f865e4f1609f9971ca19d6f40
scriptPubKey (hex)
0020a2b95877500eb4180401640c5649c55ce578584f865e4f1609f9971ca19d6f40
Spending tx
Unspent

You can also view it here: https://blockstream.info/testnet/tx/3010534df31914f938014d34d0bd402ce1a741a46624b28abcfd2462126331a5?expand

In order to spend that output, I am first creating a transaction via bitcoin-cli as such:

bitcoin-cli createrawtransaction [{\"txid\":\"3010534df31914f938014d34d0bd402ce1a741a46624b28abcfd2462126331a5\",\"vout\":0}] [{\"tb1q77vr56qx6y5vs2zzt9qc85ge62j30r6vaccfxl\":0.0000007}]

This outputs the following serialization:
0200000001a53163126224fdbc8ab22466a441a7e12c40bdd0344d0138f91419f34d5310300000000000fdffffff014600000000000000160014f7983a6806d128c82842594183d119d2a5178f4c00000000

I now try to sign the message

bitcoin-cli signrawtransactionwithwallet "0200000001a53163126224fdbc8ab22466a441a7e12c40bdd0344d0138f91419f34d5310300000000000fdffffff014600000000000000160014f7983a6806d128c82842594183d119d2a5178f4c00000000" [{\"txid\":\"3010534df31914f938014d34d0bd402ce1a741a46624b28abcfd2462126331a5\",\"vout\":0,\"scriptPubKey\":\"0020a2b95877500eb4180401640c5649c55ce578584f865e4f1609f9971ca19d6f40\",\"witnessScript\":\"4c02efef754c14f7983a6806d128c82842594183d119d2a5178f4cac\",\"amount\":0.0000007}]

This does not work however, as I always get the following error:
{
  "hex": "0200000001a53163126224fdbc8ab22466a441a7e12c40bdd0344d0138f91419f34d5310300000000000fdffffff014600000000000000160014f7983a6806d128c82842594183d119d2a5178f4c00000000",
  "complete": false,
  "errors": [
    {
      "txid": "3010534df31914f938014d34d0bd402ce1a741a46624b28abcfd2462126331a5",
      "vout": 0,
      "witness": [
      ],
      "scriptSig": "",
      "sequence": 4294967293,
      "error": "Witness program was passed an empty witness"
    }
  ]
}

I do not understand why I receive a Witness program was passed an empty witness error, as I am explicitly passing a witness script in the command line. Is there a bug or what am I missing?
The witness script that was hashed is
OP_PUSHDATA1 EFEF OP_DROP OP_PUSHDATA1 f7983a6806d128c82842594183d119d2a5178f4c OP_CHECKSIG
which serializes to
4c02EFEF754c14f7983a6806d128c82842594183d119d2a5178f4cac

The witness script you are using, 4c02efef754c14f7983a6806d128c82842594183d119d2a5178f4cac is non-standard (in the sense that it does not represent a script descriptor defined by a standard, not in the sense of relay policy). Bitcoin Core won't be able to provide a satisfying witness for a non-standard Script.
If you want to use more advanced, but still standard, scripts with Bitcoin Core have a look at Miniscript.

I see! So can you only use standard witness unlock scripts? I thought you'd be free to choose your script in a P2WSH transaction?

@BitcoinQuestioner You can use any script, but that doesn't mean Bitcoin Core knows how satisfy your script. If you use something beyond the supported scripts, you'll need to implement the signing logic yourself. Note however that through miniscript the set of supported scripts has increased a lot (but doesn't include your specific script).

I clarified that non-standard in my answer isn't about relay policy.


text:
How to determine if a public key point y is negative or positive, odd or even?
Take a bitcoin public key (x, y) and its additive inverse (x, -y). How do you identify which is the positive point and which is the negative point?
Example
Private key 1 -> (x, y)
x =  0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798L
y =  0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8L
-y =  0xb7c52588d95c3b9aa25b0403f1eef75702e84bb7597aabe663b82f6f04ef2777L
Private key 2 -> (x, y)
x =  0xc6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5L
y =  0x1ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52aL
-y =  0xe51e970159c23cc65c3a7be6b99315110809cd9acd992f1edc9bce55af301705L
Private key 3 -> (x, y)
x =  0xf9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9L
y =  0x388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672L
-y =  0xc77084f09cd217ebf01cc819d5c80ca99aff5666cb3ddce4934602897b4715bdL

Also, how can you identify which pub key is odd and which is even?
ex: private key 1 x,y is odd , private key 2 x,y is even

I don't understand the question.  x and y here are elements of the finite field F_p in which there is not generally an unambiguous meaning of "odd" and "even" - every number is divisible by 2 with respect to the field multiplication.  There is a similar issue with "positive" and "negative" since F_p is not an ordered field.

@NateEldredge, I think Prabu is looking to know whether or not the point was generated from a private key that is odd/even, not whether the resulting coordinates are odd/even.

There is no concrete determination that makes one 'y' value negative or not in an EC point. Feel free to make your own convention, like y-values <= than half of p are negative, and > half of p are positive. That's just a convention, though.
Related:

What does the curve used in Bitcoin, secp256k1, look like?

Also, how can you identify which pub key is odd and which is even?
ex: private key 1 x,y is odd , private key 2 x,y is even

You can't! Not without knowing the private key itself. If you could, you would be part of the way towards solving the discrete log problem.

Hi StephenM347, y-values <= than half of p are negative, and > half of p are positive, please can you explain this clear with some example

How would one break the discrete log problem by knowing whether the Y is positive, negative, odd, or even? Would it absolutely break the cryptography or just narrow the field search to find a private key?

@PedroGonçalves Knowing whether the Y coordinate is odd or even is of course not a break of anything, because it's public information. Knowing whether the Y coordinate is "positive or negative" depends on how you define positive or negative (as stated in this answer, you can make up your own convention). IF you define it as "the corresponding private key is even/odd", then indeed knowing whether Y is positive or negative is trivially a security break (you're not supposed to be able to infer any information about the private key).

Let's look at this more formally.
Assume that there is a function lsbPriv(P) such that it returns the LSB of the private key k from the public key P = [k]G where G is the base point.
Now, we can use this function to determine all of the bits of the private key k as follows;
func DlogbyLSB(P)
  for i in range(1..256)
    x = lsbPriv(P)
    secretKey.append(x)
    if x == 0 then    ; test the bit
      P = [2^-1]P     ; i.e. we can divide `k` by `2` since the last bit is `0`
   else
      P = [1]G        ; i.e. we substructed the bit `1` from the `k` and
      P = [2^-1]P    ; now it is again divisible by `2`
   return secretKey

This is almost like the reverse of the double-and-add algorithm that computes the scalar multiplication on the Elliptic Curves.
So, with the help of the lsbPriv we can learn every bit of the private key k. In Cryptography we call this lsb bit as hard core predicate. As we can see, after the 256 calls, the lsbPriv reveals the key. So the lsbpriv is as hard as to recover all bits.
This also implies that if such lsbPriv function exists it is equal to solving the Dlog problem on the curve Secp256k. Currently, we know that is hard so there is no such lsbPriv function.


text:
same R value is used for two different addresses? finding z1 and z2 value and privatekey
txid1
txid2
input script 1
304502206bcc247f1259262b4035bfa84f0397a69f69baa01659daaf94fe1164b650c86a022100a044b38e8264a1c928ddd28b4657aa7109d1ea30e911208c7ce57abcb1451fe601
0428f3c7982219bf067d9723a54bef8e0ae7d970b4285a148685ce98819bd59c993da6945a85ba67249e96534f3cb93af144301e3ef03f848ebf17fedd55addd14

r = 6bcc247f1259262b4035bfa84f0397a69f69baa01659daaf94fe1164b650c86a
s1 = a044b38e8264a1c928ddd28b4657aa7109d1ea30e911208c7ce57abcb1451fe6
input script 2
304402206bcc247f1259262b4035bfa84f0397a69f69baa01659daaf94fe1164b650c86a022075e41da2596619e837af69cdf80933e519abd736210677970a6ac23a3709ee2e01
04c69b120facc137ad7ecf7407b97f3e1bcecec27ed6617ad1e3bb4f5a265c2230dab461d8de9d194b9aae05cf3fc361e31b0cd172985720a9963a1fd9cb4dab13

s2 = 75e41da2596619e837af69cdf80933e519abd736210677970a6ac23a3709ee2e
Raw tx 1
010000000169590a9c08ea4d2f4d1b5e3acb216b9cee78e8378a7a5b223aff7e85f70eab77000000008b48304502206bcc247f1259262b4035bfa84f0397a69f69baa01659daaf94fe1164b650c86a022100a044b38e8264a1c928ddd28b4657aa7109d1ea30e911208c7ce57abcb1451fe601410428f3c7982219bf067d9723a54bef8e0ae7d970b4285a148685ce98819bd59c993da6945a85ba67249e96534f3cb93af144301e3ef03f848ebf17fedd55addd14ffffffff0224aece00000000001976a914b4d245551501f7f443ea507494ef00b8ed739f6888ac9def0b0f000000001976a91460a1a3a20ac1023a8b6ce202190fbf75ec73a1bf88ac00000000

calculating z1
replace the input with the corresponding output script
010000000169590a9c08ea4d2f4d1b5e3acb216b9cee78e8378a7a5b223aff7e85f70eab77000000001976a91460a1a3a20ac1023a8b6ce202190fbf75ec73a1bf88acffffffff0224aece00000000001976a914b4d245551501f7f443ea507494ef00b8ed739f6888ac9def0b0f000000001976a91460a1a3a20ac1023a8b6ce202190fbf75ec73a1bf88ac0000000001000000

then do sha256(sha256(modified transaction))
z1 = 9ffb92bc05a398e3177b12fcdac5308d316b6bd6cc00365177711dc4e3f10e64
Raw tx 2
0100000001cc41959d96ce6147b93fe00a8fca25ce99ec1a09dc175d27113db36f6e398d1c010000008a47304402206bcc247f1259262b4035bfa84f0397a69f69baa01659daaf94fe1164b650c86a022075e41da2596619e837af69cdf80933e519abd736210677970a6ac23a3709ee2e014104c69b120facc137ad7ecf7407b97f3e1bcecec27ed6617ad1e3bb4f5a265c2230dab461d8de9d194b9aae05cf3fc361e31b0cd172985720a9963a1fd9cb4dab13ffffffff02f4351000000000001976a91485ba872014004c8e4de29d94b4d7ad415297955f88acc0d06100000000001976a9149e26556775e88e000179ebe278a259cba1d7b43d88ac00000000

calculating z2
replace the input with the corresponding output script
0100000001cc41959d96ce6147b93fe00a8fca25ce99ec1a09dc175d27113db36f6e398d1c010000001976a9149e26556775e88e000179ebe278a259cba1d7b43d88acffffffff02f4351000000000001976a91485ba872014004c8e4de29d94b4d7ad415297955f88acc0d06100000000001976a9149e26556775e88e000179ebe278a259cba1d7b43d88ac0000000001000000

then do sha256(sha256(modified transaction))
z2 = 539bcbcddc3fff95aa262d01b8a909504958b371b813cb71a457efebb41c398e
priv key calculation,it not given correct address and priv anything wrong
posting the r , s1 , s2 , z1 , z2 below
http://2coin.org/tx.asmx?op=GetPrivateKeyFromIdenticalRs
it given 18MRDftXYkGqzo9hvcdnUs7yaPXrD1DXsq address
but
trans 1 address = 19owWJcPbTEe1mVYer1ymnbduJDza9jpRH
trans 2 address = 1FRDgmxVrUUNiiB7GN3NNcJDEEXtFB22rm
what's wrong

All of the encoding/decoding/math you show above looks correct to me, as are the z values you calculated. I don't understand your final question, though. Are you trying to derive a private key from just the information above (which isn't possible despite the reused k values because the private keys differ)?

Calculating the private key from a signature (r and s) requires that you know the message (to calculate the "z" value) and the "k" value (which is used by the signer to derive the r value via a trapdoor function).
Calculating the "k" value (needed above) requires two signatures (you need two s values) which sign two different messages (you need two z values) using the same private key and the same r (therefore the same k) value.
In your question, you reference two transactions signed by different private keys (which you know by noticing their public keys differ), and therefore you do not have enough information to correctly calculate the k value.
In the other similar question you recently asked, the two transactions were signed by the same private key (and they have the same r & k), so in that case it is possible to calculate the private key. (The service you linked to appears to calculate it correctly, however it doesn't display the uncompressed address.)

k=5930f1a23e39c1a223ea2fb086cbcabbdf0d09e70ba0aed342ff0f5318a542f0 priv1=5JbfQE5fTXHZxWZ8qBDRR1z6S9hAvdzPEGEWGQgn1LJRTuNtaqG priv2=5JEzySX3zHQyH4ccLNMjNzmZNJ9MoHXBfW8g4MRaPBJ3u6dH1V2

Yes, but you're "cheating" :). You're using additional broken signatures from the blockchain, I'm answering only the specific question asked. (Also your k is wrong, k = a6cf0e5dc1c63e5ddc15d04f79343542dba1d2ffa3a7f1687cd34f39b790fe51.)

Answering your question: "what's wrong"?
For each transaction you can write down an equation:
x*r + m = s*k

where x is the private key, r and s the signature. m the message hash, k the signing secret.  All calculations are modulus the group order.
You are looking at two transactions with the same 'r'.
You could write equations for those two like this:
x1*R + M1 = S1*k
x2*R + M2 = S2*k

Here I use UPPER case letters to indicate the known values, and lower case to indicate the unknowns.
The problem is that you end up with two equations with three unknowns. This cannot be solved at this point.
There is however a solution for this particular case:

Here I created a graph where each node has the first 8 digits of the r-value and x-coord of the pubkey.
The red node indicates the r-value you are interested in.
Square boxes indicates a public-key, round/oval nodes are the r-values.
The Arrows indicate a signature using that pubkey.
You can see the green arrows form a loop in the diagram.
These form four transactions as follows:
t1: r1, pub1
t2: r1, pub2
t3: r2, pub2
t4: r2, pub1

from that you can derive four equations in four unknowns, which you can solve:
x1*R1+M1=S1*k1
x2*R1+M2=S2*k1
x2*R2+M3=S3*k2
x1*R2+M4=S4*k2

Then from there you can follow all the chains and find all the other keys.
Note that this is only a small part of this network, in total there are 1814 related transactions.
A side note, that 2coin.org link no longer works, but you can do the same calculations on this page ( by me ): https://rawcdn.githack.com/nlitsme/bitcoinexplainer/aa50e86e8c72c04a7986f5f7c43bc2f98df94107/ecdsacrack.html

same r value is used for two different bitcoin addresses? finding privatekey of both address? @amaclin  can you explain briefly how did you get private key. Answer with formula and program
and @Christopher Gurnee
How you think he cheated.
There is any way to finding privatekey of both address? When same r value is used for two different bitcoin addresses. Please answer with formula and program

I have found as bellow:
p  = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
r  = 0x6bcc247f1259262b4035bfa84f0397a69f69baa01659daaf94fe1164b650c86a
s1 = 0xa044b38e8264a1c928ddd28b4657aa7109d1ea30e911208c7ce57abcb1451fe6
s2 = 0x75e41da2596619e837af69cdf80933e519abd736210677970a6ac23a3709ee2e
z1 = 0x9ffb92bc05a398e3177b12fcdac5308d316b6bd6cc00365177711dc4e3f10e64
z2 = 0x539bcbcddc3fff95aa262d01b8a909504958b371b813cb71a457efebb41c398e
K = GF(p)
K((z1s2 - z2s1)/(r*(s1-s2)))
result dec: 8921113496817264148701652880922087877926656286340189747525982520215619494205
result hex: 13b92bda88a3f2dbac6032865bf56eed68eea22d4461c77404ad79c49697e13d

It would help if you added a couple sentences to explain what you did differently than the asker.


text:
How many unconfirmed childs can I have?
I don't seem to be able to ask the right question in the title, the way I asked the question is not correct.
What I really want to know is this:
I can spend an unconfirmed output, then I can spend the output that spends that unconfirmed output, and I can spend that output, too, and so on...
My question is: how many times can I do it?

Edit: I just tried it in the testnet, I got this message: 64: too-long-mempool-chain. Is this 64 an universal number?
Edit 2: It turns out 64 is the error code. The actual number is 25.

There is no limit in the consensus rules about that. However nodes have a local policy rule about this. In Bitcoin Core, the limit is 25 unconfirmed transactions. This limit is user configurable.

How does one increase the limit? What is the bitcoin.conf setting?

I'm also curious why it never seems possible for me to reach anywhere near that limit of 25 unconfirmed transactions, before getting an 'Insufficient Funds' error. What other factors are at play here? How does one go about increasing chains in such cases, without using createrawtransaction?

@qmux You will need to increase the -limitacnestorcount, -limitancestorsize, -limitdescendantcount, and -limitdescendantsize settings to increase the limit. The Bitcoin Core wallet may be unable to reach the limit because the wallet operates with different, stricter limits.

This looks to be exactly what I’m looking for, thanks. What does usage of these configuration arguments look like? E.g. for ‘-limitancestorcount’, should this be added as a parameter in ‘bitcoin-cli sendmany {..output data} -limitancestorcount 20’ like so?

These are options to bitcoind. You either add them to the bitcoin.conf as, e.g. limitancestorcount=30, or to the command to start, e.g. bitcoind -limitancestorcount=30.

I set both limitancestorcount=50 and limitdescendantcount=50 in bitcoin.conf, as well as  spendzeroconfcharge=1 and restarted bitcoind- still facing the same ‘Insufficient Funds’ error. Could it be because I’m missing the descendantsize/ancestorsize config or is there likely another issue here?

Insufficient funds is unrelated to the unconfirmed children limit. Increasing it won't have any effect on that. Even if the wallet knows about a transaction, it may not choose to use it for creating new transactions. The wallet has additional rules on what inputs may be selected. It doesn't just choose things if it knows about them because that may not be safe.

What would be the best resources you’d recommend to help with understanding how to configure bitcoin core in such a way that it does choose to select unconfirmed transactions (those in question here only have a ‘chain’ of one 0 conf). Why would bitcoin core refuse to broadcast these transactions, especially when in the past days there’s not been any issue with submitting almost identical CPFP transactions with bitcoin core configured identically?

There are no such resources as there is no way to configure the coin selection algorithm like that. At best, you will only be able to spend unconfirmed change. Bitcoin Core does not spend from incoming unconfirmed transactions because it is unsafe to do so. The node and wallet operate fairly independently - something that is accepted by the node may not be able to be created by the wallet. The wallet isn't refusing to broadcast anything, it is refusing to create it in the first place.

Sorry, I should have been more clear - all utxos I’m looking to spend here are unconfirmed change outputs from the same wallet. Thanks for the clarification regarding the relationship between the wallet/node. As you described, the problem I’m facing appears to be the wallet refusing to include unconfirmed change output in successive transactions. What would be the best way of getting around this?

Let us continue this discussion in chat.


text:
Is it possible to brute force the Secure Element of Ledger Nano S?
Only things I could find about this subject always tell that Ledger has a secure element like SIM cards and credit cards have. Also something about another OS running near the main application. But simply when you cut the power isn't it just a storage device? SIM cards and credit cards are encrypted with a pin. I also think the secure element in Ledger is. So can an advanced adversary pull the secure element off and brute force a 6 digit PIN?

No. Secure elements are designed to be resistant to physical attacks. So you shouldn't be able to do anything physical to the chip that allows you to get data off of it. They are designed to prevent unauthorized access to their data so they also are more than just storage devices.
While you can desolder the chip and attach wires to its pins in order to interact with it physically, the chip specifications are not public and require signing an NDA. The manufacturers make it difficult for the general public to be able to know the functionality and ways to interact with the secure element. They are doing security through obscurity.
Furthermore, secure elements are generally complete systems with their own CPU, RAM, storage, etc. So it isn't just a storage device where you can get the contents. Rather they are tiny computers where you can only interact with them in a very specific way.

So by structure of it, it's a compound machine that only gives certain outputs on certain conditions? For example let's say it has a data partition, but even though you try to read from it, it doesn't give any output, and maybe even it can record it as an attempt. I can just imagine how impossible hard would it be to reverse engineer something like this. Maybe checking out everything with a microscope and trying to figure out patterns and etc. I am happy to learn that i am pretty much safe with a random 8 digit pin even though some guy just steals the device.

Yes, they are complex machines that only respond to certain inputs, with specific outputs. You could use a scanning electron microscope in order to actually try to read the data from the chip itself, but even then, they have protections in place to make this difficult. In general, secure elements are supposed to ensure that their data is safe even when the device is physically stolen.


text:
Why is there a separate bitcoin and bitcoin-core GitHub repo?
Can someone explain why these two repositories exist at the same time?
https://github.com/bitcoin
https://github.com/bitcoin-core
It is a bit confusing for a newcomer to the codebase what to actually trust.
Furthermore, is there some good intro somewhere that explains how access to this repository is managed? Like who can become eligible to approve merge requests and for what reasons could this right be stripped from a person again.
Thanks a lot!

For the merge access part/maintainers see https://bitcoin.stackexchange.com/questions/119316/who-approves-the-merger-of-github-pull-requests-to-the-bitcoin-core-master-branc

Thank you very much! That answers my questions!


text:
In the PrivateKey sign() method why are s and N-s equivalent solutions?
In the PrivateKey sign() method (Chapter 3 page 70) s is calculated like this
# s = (z + re)/k
s = (z + r * self.secret) * k_inv % N
if s > N / 2:
   s = N - s

Why does s and N - s work?
Closest I can get is (page 76) "if we know x, we know the y coordinate has to be either y or p - y", but s is not a y co-ordinate, merely the result of integer arithmetic, there's no elliptic curve math here. Is it purely a property of a prime order field (group)? In the book it's treated as something that should be obvious so perhaps I missed something or am not seeing a connection.
Thanks in advance.

The verification equation for ECDSA is
X coordinate of ((z/s)G + (r/s)Q) mod n = r

Where the divisions happen modulo the order of the curve (n), and z is the message hash (taken modulo n again). Also, while the X coordinate that comes out is a number in the field GF(p) (not GF(n)), it is interpreted as an integer, and then taken modulo n before comparison with r.
If it so happens that you have a pair (r, s) that satisfies this equation, then substituting -s (which equals n-s modulo n) gives:
   ( (z/(-s))G +  (r/(-s))Q)

Due to the fact that in elliptic curve multiplication it holds that (-a)P = -(aP) (where the first - is an integer negation modulo n, and the second - is elliptic curve point negation), it follows that:
=  (-(z/  s) G + -(r/  s )Q)
= -( (z/  s) G +  (r/  s )Q)

In other words, the result is the (point) negation of the ((z/s)G + (r/s)Q) that appears in the normal formula. Negating an elliptic curve point only changes its Y coordinate, not its X coordinate, so the result will have the same X coordinate, r, and thus the verification equation will also succeed for the signature with negated s.
Note that in Bitcoin there is a policy rule that every s needs to be between 0 and n/2, disallowing one of the two variants.

OK, got it. Nice clear explanation, thank you :-)
My confusion stemmed from me trying to get from the expression in the prior line (z + re)/k which are all integers, to a value that was being treated like two y-coordinates s and N-s.
Cheers.


text:
Is BIP324 v2transport redundant on Tor and I2P connections?
Just testing the recent BIP324 on my node, since Bitcoin Core v26 and having v2transport=1 in bitcoin.conf set, I have noticed that I am receiving some incoming connections using the v2 transport protocol to my node, which can only be reachable to incoming connection, using Tor and I2P, with my onion/I2P addresses, and if I make outgoing peer connections using the v2 transport protocol from my node to some Tor or I2P addresses, the connection is successful. It works without problems, ok.
But, considering that these two networks are encrypted by design, is it redundant to use this additional security layer for these networks? If, yes, shouldn't it only be used for ipv4/ipv6 connections to avoid this unnecessary redundancy?
Refs:
https://support.torproject.org/about/
https://geti2p.net/en/
https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki

Have you read the link you included in reference? https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki#motivation has a " Why not use a secure tunnel protocol?" section addressing BIP324 vs proxy networks (Tor, i2p, ..).

The encryption aspect of BIP324 isn't very useful on Tor/I2P, but it's pretty cheap in terms of computation power (cheaper than the old unencrypted protocol on many systems!).
We could define a slimmed-down transport protocol to be used on these privacy networks (e.g. the BIP324 packet encoding, but without encryption or authentication tags), but I think the cost of yet another protocol isn't worth the benefits.


text:
I have a 24 word seed and a passphrase - I need master private key
there's a wallet initially created by trezor using a 24 word seed and 25th word passphrase. I need the master private key of this wallet (old P2PKH format) to get access to old fork coins.
However, the 24 word seed without the passphrase is still in use, so I can't risk entering them on a live computer.
How can I get the private key info of the 24+1 words without compromising the 24 words? Is there a tool that I can use on an offline machine?
Thanks!

Which forkcoin are you interested in? Trezor supports Bitcoin Cash, which is at 0.5% of Bitcoin's value, other forks are worth even less. This might not be worth your time or the risk of accidentally compromising your seed.

If you want an easy to use option, you can use Electrum to import your wallet from the seed. Once the wallet is imported you can get the master private key. This can be done completely offline. You can even download Electrum on another computer and transfer it to your offline machine.
Here are easy steps to follow for importing https://bitcoinelectrum.com/restoring-your-standard-wallet-from-seed/
Once your wallet is imported, open up the console in Electrum and type getmasterprivate()

Thanks, I tried this but couldn't find the passphrase option. Later I think I found it: on entering seed I must go to options, select both BIP39 and extra passphrase, which opens a dialog for passphrase after going to next dialog from seed. This might work, I'll try on offline PC with the real seed soon.


text:
Should there be a Bitcoin equivalent of Tux?
Many questions on this forum center on the idea of getting Bitcoin to go mainstream. One mechanism that the Linux team employed for their distros was the idea of a mascot - the Linux penguin, Tux (see http://en.wikipedia.org/wiki/Tux).
So should Bitcoin have an equivalent? And if you think so, what would you suggest and why?

I think that this question is not very appropriate for our Q&A format. There is not on real answer to this. A discussion forum would be a better place to gather ideas.

If you start a forum thread on that, please paste a link here;).

Created a forum thread for this: https://bitcointalk.org/index.php?topic=49289.0

And it's a good thing I'm not a moderator there, because that thread is a duplicate of this one ;)

Allie the Apaca !
http://www.livanti-alpacas.com/images/photos/alpaca_horizon.jpg
A lot of the early bitcoin coverage mentioned the fact that you buy alpaca socks so I think the alpaca should be the bitcoin mascot. Obvious names are Al and Allie. I think Allie is cuter.

... and a Bitcoin badge... could be on to something here

Sure ! bitcoin need a mascot !
+1 for the alpaca, good idea
a spider could also be a good idea, typically some kind of collaborative spiders ( most spiders work alone but there are also some small ones who work together to build gigantic webs )

Hmm, not so sure about a spider - arachnaphobia is quite common and could get confused with Halloween

As the first thing that one can associate with the word "Bitcoin" is a coin, one should probably go in that direction. Since coins are not very animate in themselves and anthropomorphizing them would probably look silly, probably something that has a strong correlation with a coin is the way to go. One can think of materials - gold and silver, specific faces from the coins (which is too local to consider), and people dealing with coins and money - bankers, tax-collectors, those figures don't really have any good connotations in general. There is one more group of people that are associated with coins - pirates, which whereas can have negative connotations (digital piracy), are also considered positive in some manners (Pirates of the Caribbean, etc.). So I think we should be considering some pirate with a chest full of Bitcoins.
Alternatively, there are also other more fantasy creatures people associate with coins or precious metals - leprechauns, dwarves, and the like. Whereas those don't have much negative connotations, their positive connotations aren't very prevalent either, so I would stick with pirates.

Pirates seem to be getting a bad name in the press these days: music downloads, Somalia. But then they are also associated with liberty and freedom from authority. As a mascot, I think it might be too charged - or I might be reading too much into it.

Oh boy, please no pirates! Pirates are not positive in any way whatsoever.

"Join Bitcoin and have your coins stolen by pirates with big chests of Bitcoin!" comes to mind... maybe that's just me also though..

How about "do what you want, 'cos a pirate is free?" http://www.youtube.com/watch?v=Jbq_1Wy70rE


text:
Bitcoin Transaction Scripts
Could someone explain to me how the bitcoin transaction scripts work?How to build custom scripts?
Also please explain the data structure of transactions as specified by the bitcoin protocol? How to collect unconfirmed transactions to start mining, what is protocol API for writing python scripts to collect transactions, generate blocks, build transactions and other necessary information to build a bitcoin client from scratch?

There is no spec for a full bitcoin client that is shorter than the source code for the standard client.

I think it would be handy to develop libraries implementing the protocol methods for building transaction scripts as well as generating blocks(mining) and provide a handy interface to the bitcoin protocol just like "requests" and "twisted" libraries.

A client for transactional purposes can have less capabilities than a client that also will perform the tasks needed to support mining.
A lightweight client to review might be picocoin, "a tiny bitcoin library, with lightweight client and utils".

Nice simple library but what I was asking for is a thorough explanation to the points I mentioned above, anyway I found this post 285-bytes-that-changed-the-world.


text:
How does blockchain.info associate a message with an address?
I randomly encountered this address on blockchain.info: https://blockchain.info/address/1CzpppydnGN5dQN7iBnZbmm5RXreu7hrHW and at the top a message appears presumably describing the owner of the address. I have not seen this before. Is this just a feature of blockchain.info or is it a feature generally available in the Bitcoin system? And if so, how does this feature work?

@Nick Really? That question seems to be related to messages associated with transaction. The message above is associated with an address. Is it the same system?

Those two questions are NOT duplicates. They are entirely different questions.

This is a feature of blockchain.info only, because it is stored in their database. It is possible for anyone to associate a link ("tag") with any bitcoin address on blockchain.info, as long as it can be verified that the page the tag links to also contains the same bitcoin address.
However, the example address provided in the question contains both a link and a short message. This happens for tags that point to user profiles on bitcointalk.org. The message displayed is simply the user signature from that forum.

This is known as "tags", and it is 'blockchain.info' specific. You can use any web page, or bitcointalk.org user profile or bitcoin-otc Id as link. Your link page should contain your address.
http://blockchain.info/tags

I tried to tag my address and specified twitter status as link. Tagging was successful, but verification failed. :-)

I have tagged one my addresses but it doesn't show up this way. In addition the tag only specifies a label not a long text message. It doesn't seem to be the same feature to me.

I think I figured it out now. You can't actually get a custom message when you submit a tag, however the tags from BitcoinTalk profiles automatically get the message from the signature that the user has defined on that forum.


text:
Which language has better Bitcoin API experience, C# or Node.js?
At the moment it seems to me on the .NET side NBitcoin would compete with Bitcoin.js on the other.
Update: I decided on NBitcoin. It has a great book to learn from.
Note I will not form opinion on my question, I contributed a great chunk of this book, so I would be biased.

Can you clarify what kind of service you are building? Exchange, market place? Raw Bitcoin transactions? From the experience, Python has really really strong Bitcoin support. In any case node.js and Bitcore from Bitpay is one of the most high quality libraries available https://github.com/bitpay/bitcore

I'm working at a payment processor company and we are about to set up a crypto division. Based on the experience of my team we have to decide which platform we're going to stick with regarding to bitcoin.

This is a shameless plug, but I wrote this library for Bitcoin you might want to check out: http://cryptoassetscore.readthedocs.org/ - It's based on my experiences working in a Bitcoin exchange. The library does a lot of things "right" like accounting and transactions and e.g. make race condition based issues and attacks impossible.

It's very secure. If you are a payment processor company I'd suggest you to read through at least this page: http://cryptoassetscore.readthedocs.org/en/latest/integrity.html

Also big Bitcoin exchanges (LocalBitcoins, Bitstamp) use Python

API selection with other technology selection is having major dependencies on final goal. so you have to select the best suit of technology as per the business requirement.

Upvoted, because it's true. However I won't mark it as "best answer", because it is incomplete. In order to "to select the best suit of technology as per the business requirement" one needs a proper comparison on the opportunities the bitcoin frameworks of the two languages provide to make an educated decision.


text:
Mixing Unequal Inputs
Let's say have 3 inputs (alice, bob, satoshi): 0.3, 1.3, 1.6.
We can mix these inputs for example like this: 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.1, 0.1.
Or like this: 1.3, 1.3, 0.3, 0.3.
Traditionally it is mixed like this (CoinShuffle/ZeroLink/BlindCoin): 0.3, 0.3, 0.3, 1, 1.3.
There are many combinations, but there are better and worse mixes. I intuitively figured I want to anonymize the most bitcoins in the cheapest way.
First take the sum of the anonymity sets weighted by the amount of bitcoins. With the second mix example (1.3, 1.3, 0.3, 0.3) it would be:

alice: 0.3btc - 2/1=2 anonset -> 2*0.3=0.6
bob: 1.3btc - 2/1=2 anonset -> 2*1.3=2.6
satoshi: 1.3btc - 2/1=2 anonset -> 2*1.3=2.6 AND 0.3btc - 2/1=2 anonset -> 2*0.3=0.6

And the sum is: 0.6+2.6+2.6+0.6=6.4
Next we want the cheapest possible mix, for this we need to minimize the number of outputs, in the second example it's 4. Finally divide the number of outputs by the weighted anonset sum: 6.4/4=whatever (1.6).
We want this whatever number to be as high as possible. This is how we can anonymize the most bitcoins the cheapest way.
With the traditional mix, whatever would be 5 weighted anonset sum / 5 output number=1.
So the my ad-hoc 2nd algorithm exactly 60% more efficient.
I also wrote a little software that compared 3 different algos with 100 random inputs (results below).
The first goes like this: take always the smallest input and pair it up with the rest. This generated many outputs (as you can see it created so many outputs, that it overflow by 173% of the standard maximum Bitcoin transaction size.)
The second algo always took the second greatest input and paired it up with the greatest.
During the third algo I used middle out, so I took the middle input and paired it up with as many inputs as possible. This provided by far the best whatever value: 149.

Test code: https://github.com/nopara73/ConsoleApp14/blob/master/ConsoleApp14/Program.cs
What algorithm can lead to the most optimal mix?

Are you aware of https://www.comsys.rwth-aachen.de/fileadmin/papers/2017/2017-maurer-trustcom-coinjoin.pdf ?

I wasn't, thanks. I coded it and added to my tests, but it doesn't give optimal combinations, even if you try all possible Knapsack combination and only go with the best, the middle-out algo above consistently performs better.

I don't have an answer to your question directly, but it's worth pointing out that anything other than 32 x 0.1btc inputs and 32 x 0.1btc outputs provides worse anonymity. Even having 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.1, 0.1 gives away some information that likely 2 of the inputs were 0.1btc above a number divisible by 0.3. Maybe there's a peak on a benefit/cost curve, but it's still a trade-off against privacy. There are other solutions outside of Bitcoin (that vastly improved on the concepts of coinjoin) like MimbeWimble which do what it sounds like you want in terms of cheap coinjoining, but with other benefits too, that Bitcoin is unable to implement because of its design

Another con I learned in the meantime that with fixed denominations perfect remixing is possible, which increases anonymity greatly. This of course not to say the pros don't outweigh the cons, it's just a more elaborate concept is needed to evaluate and research these ideas.


text:
What is the correct Bitcoin.org wallet download?
anyone able to install the Bitcoin Wallet?
Apple store is taking me to Bitcoin Wallet from COINiD, doesn't seem right?

Does the Bitcoin Wallet handle the Lightning Network?
Can the Bitcoin Wallet send random amounts or does it need a Lightning Invoice to pay with an exact amount?

What is the correct Bitcoin.org wallet download?

Bitcoin.org is not an official Bitcoin website, no website is. It long ago ceased to be run by the original developers and was taken over by others.  I suspect it no longer follows its original goals of impartiality.
You should choose wallet software carefully.

Worth noting as some may be unaware. This seems to be a useful URL for wallets https://walletscrutiny.com/ I'm looking for a self custody, Lightning, reproducible, can pay random amounts without an invoice wallet.


text:
How long does Bitcoin Core store forked chains?
If I am not wrong Bitcoin Core stores "natural" forks in case at some point that fork is the most PoW chain and has to set it as the new tip.
How much time does Bitcoin Core store information about forks? And what kind of information does it store? Blocks + a backup for the UTXO and mempool at that moment?
In this question they say all blocks, is that true? Does that make sense?

How much time does Bitcoin Core store information about forks?

Forever. When pruning is enabled, after some time block data is deleted regardless of whether it's in the main chain or not.
Note however that Bitcoin Core will only download and store blocks along chains which, at some point, have the potential to become the best known chain. If someone announces headers to you of a fork, but those headers do not have enough combined proof-of-work to beat the chain you already have, its blocks will not be downloaded. In particular, this means that during initial synchronization you will generally not see any forks.

And what kind of information does it store?

Block headers are stored forever. Block data is stored until it is pruned (if that is enabled, forever otherwise). The UTXO set and mempool are only maintained for the current time, at the tip. If a reorg happens, the effects of the currently-active chain are rewinded, and the effects of the new chain are applied, to both the UTXO set and mempool.

Might also be worth mentioning that information about forks is only ever stored in the first place if the node was encountering the fork in real time when it happened. A new node syncing up will not have any data about historical forks.


text:
Bitcoin Core Unbuntu Custom Data Directory Does not Navigate to Secondary Internal Hard Drive
I have a laptop computer with 2 solid state internal 1000 GB hard drives. I have the operating system installed on drive 1 and I have the secondary drive formatted (ext4 file system), partitioned and mounted to /media/valdy/Bitcoin.
I can navigate to that location via the terminal and via files GUI.
I have installed bitcoin core via Unbuntu Software GUI.
I run bitcoin core GUI and select the option to "use a custom data directory". I try to navigate to /media/valdy/Bitcoin and i can't. It does not see the user folder "valdy" inside the media folder. I can type the path in and it gives me the correct available disk space for the drive. But when i hit enter i get the following error "Error: Specified data directory "/media/valdy/Bitcoin/bitcoin-core/common/.bitcoin" cannot be created.
Please advise how i can go about putting the data directory on a separate hard rive that i want to dedicate to all things bitcoin-core.

Have you checked permissions of all elements of the path? What is the EUID of the Bitcoin-qt process?

I know its a lite late but this fixed for me: https://askubuntu.com/questions/1328448/official-bitcoin-client-fails-to-start-with-error-initializing-settings-failed


text:
Bitcoin confirmation
How to finish up conformation process on bitcoin

Does this answer your question? Is it normal to be asked for an advance fee on a withdrawal?

This is a scam.
In the real Bitcoin network, confirmation of transactions happens without the recipient of the money needing to do anything.
Asking you to pay money to a "confirmation address" is, to me, a clear sign of fraud.
I believe the web site you are using, or the email you have received, is fraudulent and that you have been tricked by criminals.
My advice is

Do not send any money to that "confirmation address".
Report fraud to your local police
If you already paid money, do not expect to ever get it back. Move on with your life.
Do not engage with anyone offering recovery services. Because you have been tricked once, criminals view you as a prime target for further trickery and theft.


text:
What is the byte-wise xor operation mentioned in bip 340?

Let t be the byte-wise xor of bytes(d) and hash_BIP0340/aux(a)

Link: bip-0340
Actually, I think it means bitwise xor, not bytewise xor, but for the sake of clarity, I ask: What is the difference between bytewise xor and bitwise xor?


text:
Is there any benefit from creating hardened child keys from unhardened parents?
In the context of BIP32, is there any benefit from deriving a hardened key from an unhardened parent? E.g., m/0'/0/0'? Are there any examples of where such a key is being used?

No, there generally is no benefit to use hardened derivation following unhardened derivation. I'm also not aware of anyone using such a construction. However there are test vectors that do this since it is a supported operation, even if not useful
The purpose of unhardened derivation is to be able to derive further keys from it without needing the private key. However hardened derivation requires a private key in order to derive, and that defeats the purpose of using unhardened derivation in an earlier step.

Could there possibly be a complex usecase that makes sense where you have multiple levels of trust between different parties?


text:
Anyone know of an API I can get historical price time series for multiple coins
I'd like to build some historical price charts, to use in my cryptocoin portfolio tracking app, using time series data (with HighCharts js).
Anyone know of an API that provides this price data, preferably for multiple coins (btc, ltc, eth, etc)?

Found the data on crypto compare
const endpoint = 'https://min-api.cryptocompare.com/data/histoday?aggregate=1&e=CCCAGG&extraParams=CryptoCompare&fsym='+ ticker.toUpperCase() +'&limit=365&tryConversion=false&tsym=' + currency.toUpperCase();

I am developing the ccxt cryptocurrency trading library, check it out on GitHub:
https://github.com/kroitor/ccxt
It is a library for cryptocurrency trading and e-commerce with support for many bitcoin/ether/altcoin exchange markets and merchant APIs.
With it you can access market data and trade bitcoin, ether and altcoins with more than 70 (!!!) cryptocurrency exchanges. It is used to connect and trade with crypto markets and payment processing services worldwide. It provides quick access to market data for storage, analysis, visualization, indicator development, trading strategy backtesting, bot programming, building trading algorithms on top of it, webshop integration and related software engineering.
The codebase is in JavaScript / Python (2 and 3) / PHP. You can deploy it from PyPI, with npm (for Node.js) or by cloning the GitHub repository.
The ccxt library is under heavy development right now, but already offers a quick-start for trading and technical analysis with many crypto exchange markets out of the box. It is intended to be used by coders, developers and financial analysts to build algotrading strategies on top of it.

You have copy & pasted this answer on a bunch of questions. Self-promotion is fine on stackexchanges, but please provide a specific & relevant answer.

Sorry, I thought that it actually offers one of possible answers to the question. Doesn't ccxt API provide data that was requested by the original author in the first place? Moreover, the library fetches that data from first-hands, namely the exchanges themselves, which is very nice, not from just some aggregator. I thought it would be useful right here. Yes, I copypasted the answer, but I did that to relevant questions only. So, it's not entirely self-promotion, otherwise it would be useless and my answer would not get any points from stackexchanges' users, right? My apologies.

http://www.cryptocoincharts.info
Advance API to more than 100 exchanges: cryptocurrency pricing, OHLC and volume data from multiple exchanges.
BTC38, BTCC, BTER, Bit2C, Bitfinex, Bitstamp, Bittrex, CCEDK, Cexio, Coinbase, Coinfloor, Coinse, Coinsetter, Cryptopia, Cryptsy, Gatecoin, Gemini, HitBTC, Huobi, itBit, Kraken, LakeBTC, LocalBitcoins, MonetaGo, OKCoin, Poloniex, Yacuna, Yunbi, Yobit, Korbit, BitBay, BTCMarkets, QuadrigaCX, CoinCheck, BitSquare, Vaultoro, MercadoBitcoin, Unocoin, Bitso, BTCXIndia, Paymium, TheRockTrading, bitFlyer, Quoine, Luno, EtherDelta, Liqui, bitFlyerFX, BitMarket, LiveCoin, Coinone, Tidex, Bleutrade, EthexIndia and the list seems to grow every day.

ClueDex offers a full API for getting historical tick and OHLCV candle data from the Bittrex exchange. You can sort, order, and get data between specific dates. Supported returned formats are a JSON object or CSV for easily importing into any app.


text:
Block Chain Library
I was wondering if there are any open source blockchain libs that I could use to build a project with?
UPDATED
I agree. With my knowledge of bitcoin now and blockchain - I should have phrased this question better.
What I am looking for is a pure blockchain implementation (lib) that can be used to implement anything I want on top of it, one implementation could be bitcoin.
This "blockchain 2.0" would not have the same limitations as blockchain today (hardcoded values, flexible message size, enhanced scripting language, etc..).
Lots of startups, companies, etc... implement their own blockchain because the bitcoins'version has been designed for bitcoin - it has not been designed to deal with other business problems.
Now I hope you see what I mean. But now I understand that I have to either do a hardfork of "bitcoin" and strip out "blockchain" - or I can try to find this "blockchain 2.0" that - for example - bitcoin could fork and be based on.
Do not be too quick to mark down. If it would be obvious, I would not ask for it ;-)

I'm unsure if you've researched this. Maybe specify a language to help get this moving, or what capabilities you need from the library.

Just basically a "blockchain" lib allowing me to send tx to a set of peer-to-peer nodes - visualising the chain - having a miner with a pluggable proof-of-work algo...  Might be too painful to find as opposed to re-write it knowing the concepts?

Actualy, as a language, ideally, in Java

I get why people are downvoting, but I've had an extraordinarily difficult time finding relevant Google hits... to the point where the library will dictate the language.  I wish people wouldn't be so downvote-happy and instead take the context of the question into account.

Bitcoinj is based on Java and allows you to send transactions to the network. Its an implementation of the Bitcoin Protocol. However, it doesn't provide any way to visualize the blockchain (it only stores 646kb of the blockchain, not all 30gbs). You should improve the question to descrbe what exactly ou want to do!

I want to use blockchain without bitcoin. I can visualise the chain easily... Is the blockchain API (validation, pow, insertion, etc.) done in a way it can be extracted out from bitcoinj and used independently. Checking the source code....

I know bitcoinj - but I have edited my question. I could just strip out the blockchain implementation and expose it via services to be called by any implementer, one being bitcoin


text:
How can I request payment to a set of addresses?
I am building a payment processing service where a single payment may be split among multiple individuals. While it would be possible for me to write the service in such a manner that a customer pays to a single address, and then an secondary process creates the single-input-many-output transaction, it would be preferable if I could simply request that the transaction signed by the customer directly produce the desired outputs.
Is there any standard way to create such a payment request? Bitcoin URLs allow only a single address (and single amount) to be specified. Is there a way to create a partially complete transaction (specifying multiple outputs) in such a way that a customer's wallet software can correctly choose and fill in the appropriate UTXOs for inputs, and add an another output for the change?
Barring that, is there any precedent (and convenient method) for asking customers to provide UTXOs to use as inputs, and then generate the transaction for them to sign? I know that all this would be achievable if I were to provide custom wallet software, but that's certainly something I wish to avoid if possible.
EDIT:
I've found https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki, which seems to be close to what I want; how widely supported is this protocol?

It appears that the Payment Protocol is, indeed, what I want, and it is relatively widely supported according to this comparison page: https://bitpay.com/docs/wallets


text:
Did uncompressed public keys use the `04` prefix before compressed public keys were used?
Have uncompressed keys always used the 04 prefix, even before compressed keys (which use 02, 03) were used? Did bitcoin undergo an update to add these prefixes to the different key types? If so, since these prefixes are included in the hash used to produce addresses, did addresses using uncompressed keys "change" when compressed keys were introduced?

Have uncompressed keys always used the 04 prefix, even before compressed keys (which use 02, 03) were used?

Yes.

Did bitcoin undergo an update to add these prefixes to the different key types?

There was no update to add prefixes.
Bitcoin wallet software did however undergo an update to make use of these compressed keys. There was no change to the consensus rules/implementation needed, because at the time OpenSSL was used for signature validation, and accepted both compressed and uncompressed public keys. In fact, there is a third type that was (and still is!) supported, hybrid keys, which use prefix 06 or 07 (depending on even/odd Y coordinate), followed by 32-byte X, and 32-byte Y coordinate. I do not understand the motivation for having such a type, but it is part of the implemented specification.

If so, since these prefixes are included in the hash used to produce addresses, did addresses using uncompressed keys "change" when compressed keys were introduced?

If these prefixes were indeed not present at first then introducing them would have been a hard fork. Thankfully, no change was necessary.
Of course, wallets transitioning from uncompressed to compressed pubkeys did need to change addresses. But ony the receiver cares about the distinction, as the sender only sees the 160-bit public key hash. At spend time, the receiver needs to reveal the full public key, whose hash needs to match the public key hash sent to.
If you have an extremely old Bitcoin Core wallet.dat file that has never been updated, and load it into a very modern Bitcoin Core 27.0 software, it will still produce P2PKH addresses using the uncompressed public key, so that one can still go back to old versions. This will not keep working however, as legacy wallet support is scheduled to be removed from Bitcoin Core. Such old files will still be usable, but will need to be converted to a modern format first.
Also note that since the introduction of compressed public keys, there have been actual new address types (with corresponding consensus changes): P2SH, segwit, and taproot.


text:
How to sign SegWit Transaction without using third party libraries (step by step)
I have a PSBT transaction. My code parsed it into its component parts: 3 maps - global input, output. I based on the document 1. I parsed each transaction into separate fields. Found all scripts and their type, and got a private key for scripts.
What steps need to be taken to sign the transaction, without using third-party libraries, step by step (which fields should be used)

It's difficult to answer your question without more information. Can you provide an example? What languages are you using? Is using bitcoin-cli an option?

I write ma stack on C ( embedded application). I need an understanding of what needs to be done. In the python, c++ source code and documentation, the field names do not match.

This might help, as it at least gives a full example in Golang: https://bitcoin.stackexchange.com/questions/96283/how-to-sign-a-psbt-transaction

Now you need to understand how class members correspond to transaction fields. link

Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.


text:
I was asked to download trust wallet and was than sent around $5000 in watch only. Than was told to ask to access Bitcoin on my cash app. Is it real?
I was asked to download trust wallet and was than sent around $5000 in watch only. I than was told to ask to access Bitcoin on my cash app. They said to access Bitcoin and than send a screenshot after it’s done. Is it real or a scam? Do they have a way to get me?

Does this answer your question? Someone else created a wallet for me to use. Is this a scam?

Also see: https://bitcoin.stackexchange.com/questions/115039

Sounds like a scam to me.
A watch only wallet does not allow you to spend the bitcoin within it as it only consists of public keys.
In order to send funds to CashApp, you would have to have the private key, which you clearly don't have.


text:
Raw Transaction decoding fails on signet but decodes fine in BlockCypher decoder
Type of transaction:
p2wpkh transaction creating a multisig (p2wsh) on signet.
Error:TX must have atleast one inputs.
Output on online decoder
{
    "addresses": [
        "tb1q94nuuw96ye4x3u8hc3nga8g02kzvdknug49ucgmgh70l7yqn29ts56cl57",
        "tb1q6ajhfx4xvscts4m9hhk7ujy0tl3us25wu97pkv"
    ],
    "block_height": -1,
    "block_index": -1,
    "confirmations": 0,
    "double_spend": false,
    "fees": 0,
    "hash": "0fa2e7ac35739d727d1298922906127cdfe04040b98051f06314dc137d319a41",
    "inputs": [
        {
            "age": 0,
            "output_index": 365,
            "prev_hash": "e748d035309c2f7312176789f6fbe77a20582733817ed66b19fc675bfc1c4208",
            "script_type": "empty",
            "sequence": 4294967295
        }
    ],
    "lock_time": 2888877058,
    "outputs": [
        {
            "addresses": [
                "tb1q94nuuw96ye4x3u8hc3nga8g02kzvdknug49ucgmgh70l7yqn29ts56cl57"
            ],
            "script": "00202d67ce38ba266a68f0f7c4668e9d0f5584c6da7c454bcc2368bf9fff10135157",
            "script_type": "pay-to-witness-script-hash",
            "value": 1000000
        },
        {
            "addresses": [
                "tb1q6ajhfx4xvscts4m9hhk7ujy0tl3us25wu97pkv"
            ],
            "script": "0014d765749aa66430b85765bdedee488f5fe3c82a8e",
            "script_type": "pay-to-witness-pubkey-hash",
            "value": 8093449
        }
    ],
    "preference": "low",
    "received": "2024-02-09T10:13:35.159062502Z",
    "relayed_by": "3.235.156.159",
    "size": 202,
    "total": 9093449,
    "ver": 2,
    "vin_sz": 1,
    "vout_sz": 2,
    "vsize": 145
}

Manual decoding
nVersion
02000000

marker
00

flag
01

txin
01
08421cfc5b67fc196bd67e81332758207ae7fbf689671712732f9c3035d048e7 // 32 bytes (txid reversed little endian)
6d010000
00
ffffffff

txout
02
40420f0000000000
22 00202d67ce38ba266a68f0f7c4668e9d0f5584c6da7c454bcc2368bf9fff10135157 // 34 bytes script
097f7b0000000000
16 0014d765749aa66430b85765bdedee488f5fe3c82a8e // scriptpubkey for change

witness
02
473045022100a5faff9808555961e9ff213550b365ef86b993e07116fe445f27594f96f8798c022067571f9e0050f6c7e50057dd0e628613dffe1b573f48697019b6aa0fe97d658e01
2102c430ac1cb8ea090e63d171df5502ed5815ba579c6b38dd13e069e96816e4d247

nLocktime
00000000

Output of an accepted transaction
{
    "addresses": [
        "tb1qzeuvnr6u39npxdaxmhhxwwn68w5rplwet350nr",
        "tb1qk3qesjjnpztf2fs3r80haq9uddnw495f96w9tk5mdxyz8htuxu9qcwcurs"
    ],
    "block_height": -1,
    "block_index": -1,
    "confirmations": 0,
    "double_spend": false,
    "fees": 0,
    "hash": "33128f3a32d65c30f5bb4d4c2419f4c4e5c9c601e091c180e17592bda0ad10b3",
    "inputs": [
        {
            "age": 0,
            "output_index": 0,
            "prev_hash": "71e6a41254dc239a285e5cbf5cded15e099e18989b10ee10e23daed9e5fe052f",
            "script_type": "empty",
            "sequence": 4294967295
        }
    ],
    "outputs": [
        {
            "addresses": [
                "tb1qk3qesjjnpztf2fs3r80haq9uddnw495f96w9tk5mdxyz8htuxu9qcwcurs"
            ],
            "script": "0020b441984a53089695261119df7e80bc6b66ea96892e9c55da9b698823dd7c370a",
            "script_type": "pay-to-witness-script-hash",
            "value": 1000000
        },
        {
            "addresses": [
                "tb1qzeuvnr6u39npxdaxmhhxwwn68w5rplwet350nr"
            ],
            "script": "00141678c98f5c89661337a6ddee673a7a3ba830fdd9",
            "script_type": "pay-to-witness-pubkey-hash",
            "value": 888318652
        }
    ],
    "preference": "low",
    "received": "2024-02-09T10:17:43.206930294Z",
    "relayed_by": "18.213.115.114",
    "size": 235,
    "total": 889318652,
    "ver": 2,
    "vin_sz": 1,
    "vout_sz": 2,
    "vsize": 153
}

Raw transaction
0200000000010108421cfc5b67fc196bd67e81332758207ae7fbf689671712732f9c3035d048e76d01000000ffffffff0240420f00000000002200202d67ce38ba266a68f0f7c4668e9d0f5584c6da7c454bcc2368bf9fff10135157097f7b0000000000160014d765749aa66430b85765bdedee488f5fe3c82a8e02473045022100a5faff9808555961e9ff213550b365ef86b993e07116fe445f27594f96f8798c022067571f9e0050f6c7e50057dd0e628613dffe1b573f48697019b6aa0fe97d658e012102c430ac1cb8ea090e63d171df5502ed5815ba579c6b38dd13e069e96816e4d24700000000

The signature is 72 bytes long, but the signature witness item is prepended with the byte 0x47 (71), not 0x48 (72). The decoder then interprets the last byte of the signature (the sighash flag, 0x01) as the length of the second witness item, and parses it as 0x21. The next 4 bytes (0x02c430ac, converted to decimal as 2888877058) are interpreted as the locktime, and that's where the transaction is supposed to end. Apparently BlockCypher silently ignores any remaining bytes.
If you replace the 0x47 byte with 0x48, the transaction will decode correctly.


text:
How can I effectively trace code paths for fuzz testing in a Bitcoin core?
I want to write a fuzz test to increase the coverage of net_processing.cpp for this piece of code. But I am unable to navigate/trace from where this function is being called .
I have checked in net_tests.cpp and transaction_tests.cpp in whose piece of code RelayTransaction function was used but its not being used in tests .This would mean its being called inside tests internally . This picture is from the total_coverage generated from lcov .

How should i go about writing the test ?

It seems you are asking for an explanation of the code? And actually of a good chunk of the relay logic.

@AntoinePoinsot My wording might not have been clear for this question . I want to ask about how should one go about navigating to specific lines when fuzzing . Ideally some fuzzers or compilers would give the trace of the execution when calling functions so it is easy to navigate what was called and so. However I dont know if such thing is possible while writing tests for bitcoin-core. I wanted to ask how developers would write tests when in these scenarios ?

This chunk of code comes from one of the PR I am reviewing and I wanted to code test for this to increase coverage . I just cant figure out where this function is being hit .

I’m voting to close this question because i don't think it's appropriate for this site to explain the Bitcoin Core codebase (outside of maybe very specific snippets but it's clearly not the case here).

@AntoinePoinsot: It seems to me that asking about Bitcoin Core’s behavior would be on-topic. However, the confusion here might be stemming from the section of code being inactive in that PR and therefore not triggering because it’s part of an unfinished feature.

I agree. What i meant is that we can't explain how the C++ codebase work, unless it's very specific snippets of code.


text:
Bitcoind python connection
I'm trying to connect to bitcoind with python3. I'm currently following the instructions of Antonopolous book.
This is my code on an IDE:
from bitcoin.rpc import RawProxy
p = RawProxy()
info = p.getinfo()
print(info['blocks'])

Unfortunately I only get warnings:
/home/pariya/python_pr/venv/bin/python /home/pariya/python_pr/main.py
Traceback (most recent call last):
  File "/home/pariya/python_pr/venv/lib/python3.10/site-packages/bitcoin/rpc.py", line 190, in __init__
    with open(cookie_file, 'r') as fd:
FileNotFoundError: [Errno 2] No such file or directory: '/home/pariya/.bitcoin/.cookie'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pariya/python_pr/main.py", line 5, in <module>
    p = RawProxy()
  File "/home/pariya/python_pr/venv/lib/python3.10/site-packages/bitcoin/rpc.py", line 313, in __init__
    super(RawProxy, self).__init__(service_url=service_url,
  File "/home/pariya/python_pr/venv/lib/python3.10/site-packages/bitcoin/rpc.py", line 197, in __init__
    raise ValueError('Cookie file unusable (%s) and rpcpassword not specified in the configuration file: %r' % (err, btc_conf_file))
ValueError: Cookie file unusable ([Errno 2] No such file or directory: '/home/pariya/.bitcoin/.cookie') and rpcpassword not specified in the configuration file: '/home/pariya/.bitcoin/bitcoin.conf'

Process finished with exit code 1

I'm running bitcoind on an external hard drive. Is something missing in my code?
Thankful for any help.

Two important errors in the output you present are:
FileNotFoundError: [Errno 2] No such file or directory: '/home/pariya/.bitcoin/.cookie'

and
ValueError: Cookie file unusable ([Errno 2] No such file or directory: '/home/pariya/.bitcoin/.cookie') and rpcpassword not specified in the configuration file: '/home/pariya/.bitcoin/bitcoin.conf'

The later says that you did not provide RPC password via configuration file and cookie file is missing too.
You probably missed some init steps in your code (to login to bitcoind RPC server) or you should create a file /home/pariya/.bitcoin/bitcoin.conf and configure RPC password there:
rpcuser=johndoe
rpcpassword=enteryourpassword

Please note that the values of these parameters must match those configured in bitcoind obviously.

I don't know why it is searching for the file in my home directory. My bitcoin directory is on the external hard drive. I also have the conf file with a set rpcuser and rpcpassword in it.

Although bitcoind is placed on external drive, your code and the python library acts as a client and it look for the config in the default location.
Also, if the package you use is bitcoin (see https://pypi.org/project/bitcoin/), it's not maintained anymore and it could be quite outdated. I would look for some up-to-date package, e.g. bitcoin-utils (https://pypi.org/project/bitcoin-utils/) could do the same thing you are looking for.

Your script seems to not be able to find the cookie file, necessary to authenticate to bitcoind. Most likely bitcoind is not running on the right network.