text:
Project on modelling Bitcoin blockchain data
I am doing a thesis project on modelling Bitcoin blockchain data, but atm I am having trouble getting data from the Bitcoin blockchain into a format that is easy to deal with in e.g. Python.
I have all data from Bitcoin Core, do you know a way to aggregate the data, into a format that would give an idea about users balance or something like this?
If you have ever done a similar project, I am very interested in what you have done in the preliminary phases!
Thanks.

Address balance is possible but, user balance is not.

I've seen work, where the base their userID's on probabilities that addresses are the same user. This way it is possible to (with some probability) estimate the number of users and thereby the balances of specific users.
It was something like this I was thinking about.

As to how to convert anonymous transactions to "users" (at most a statistical attempt, as Bitcoin is in principle anonymous), which could lead to your requested "users balance" info, there are papers available that describe the process. These for example could serve as a start point (with good descriptions and images):

"An Analysis of Anonymity in the Bitcoin System" by Fergal Reid and Martin Harrigan
"Analyzing the Bitcoin Network: The First Four Years" - Matthias Lischke and Benjamin Fabian, Institute of Information Systems, Humboldt-Universität zu Berlin, Spandauer Str. 1, 10178 Berlin, Germany (CC BY 4.0)

Basically, citing the latter:

... a “user” is a grouping of public keys that were used as inputs into a single transaction (user owns the private key to each address) ...

As for the troubles using Python directly to treat raw data, you can use, perhaps as template or to get ideas, this post which uses Python to convert binary block header data to a CSV:
#!/usr/bin/env python
# convert binary file http://headers.electrum.org/blockchain_headers
# to CSV ASCII

import binascii

STRUCT_OF_BLOCK = [ 4, 32, 32, 4, 4, 4 ] # blockchain_headers does not contain always "0x00" txn_count
BLOCK_SIZE = sum(STRUCT_OF_BLOCK)

FILE_OUT= open('blockchain_headers.csv','w')

FILE_OUT.write( "version,prev_block,merkle_root,timestamp,bits,nonce,txn_count\n" )

with open('blockchain_headers','rb') as FILE:
    block = FILE.read(BLOCK_SIZE)
    while block != b'':
        position = 0
        for i in STRUCT_OF_BLOCK:
            FILE_OUT.write( bytearray(binascii.hexlify( block[position:(position+i)][::-1] )).decode('ascii') + ',')
            position += i
            if position >= BLOCK_SIZE:
                FILE_OUT.write("00\n") # blockchain_headers does not contain always "0x00" txn_count
        block = FILE.read(BLOCK_SIZE)


text:
Bitcoin Core data to csv
I would like to download the Bitcoin blockchain and use the data for machine learning purposes. For this, I have to get the data into a workable format like csv or a flat JSON etc.
I've read about approaches and the most common one seems to be through a monkeyDB. Do you know a source code that implements this method? Or do you know other methods that could be used to get the Ethereum blockchain data into a modeling friendly format?
Thanks!

Are you talking about the ethereum blockchain or bitcoin ?

I am talking about Bitcoin blockchain. The reason I mention Ethereum is, that if the Ethereum blockchain is easier to parse and aggregate data from, I could use this data instead of Bitcoin data.

I was trying to do the same thing, however, there's no explicit source of blockchain data on the internet. You'll have to download the entire blockchain transaction history by downloading Bitcoin Core to have the data at the first place. Then you'll need some parser to convert the data in raw format to more readable formats like csv or JSON.

I have downloaded Bitcoin Core and have all data available. I have some flat csv's, but need to get these aggregated and extract features from the data. The flat csv's I have is: Transactions, Blocks, tx_in, and tx_out.
Do you have any experience on how to aggregate this data into e.g. users with a certain balance.

I've seen different parsers, but haven't got to the level of any meaningful analysis. But I would assume it would be hard once the data is parsed, since it's already in a nice input/output format.

We just released the full bitcoin blockchain data in JSON format, together with methods and tools to collect and process them.
See your paper:
Full Bitcoin Blockchain Data Made Easy
Comments welcome!

source: Stack Exchange

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

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

sort: votes


text:
Bitcoin node 403 json-rpc
have read all possible examples on the internet but still cannot connect to btc node from Java.
I'm using btcd-cli4j but have tried all other rpc libs as well, result is the same.
This is the command:
BtcdClient client = new VerboseBtcdClientImpl(httpProvider, "127.0.0.1", 8332, "foo", "bar");

This is the docker image:
version: '3.3'

services:

bitcoind:
image: seegno/bitcoind:latest
command:
  -printtoconsole
  -regtest=1
  -rest
  -rpcallowip=172.18.0.2
  -rpcuser=foo
  -rpcpassword=bar
  -rpcport=8332
  -server
  -logips
  -debug=rpc
ports:
  - 8332:8332

Have tried couple of different docker images as well. Always the same:
Exception in thread "main"
HttpLayerException(super=CommunicationException
(super=com.neemre.btcdcli4j.core.http.HttpLayerException: Error #1003001: The server responded with a non-OK (4xx) HTTP status code. Status line: HTTP/1.1 403 Forbidden, code=1003001))

My suspicion was around rpcallowip but don't know how to set correctly. This one is set by going into the docker container and executing hostanme -i to see the ip address. Setting that one in config and restarting the container.

I suspect that you are actually connecting to the RPC service since you are getting a 403 status returned and not a timeout. Does it work if you remove -rpcallowip=172.18.0.2?

I would say that as well but cannot get a correct response. When removing it I'm getting Error #1004004: The operation failed due to an unknown IO exception.

add or changed to
rpcallowip=0.0.0.0/0

this will fix most of rpc json 403 forbidden error (this has no security issues if your using it within your network)

I would have sworn I've tried this multiple times but heh, it is working now, that is all that matters :)

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


text:
Is there any way to receive Bitcoin Testnet payments?
I'm currently working on the implementation of an ERC_20 Token on the Ethereum blockchain. However, I want to allow users to pay with BTC as well. I've already found several services which give me what I need (blockchain.info, bitcoin-receive-payment etc.) However, I cannot find any information on how I can test these (or any) solutions on the Testnet.
There will surely be some gotcha's during development, and I'd rather not mess around with real BTC while I'm at it. Is there any BTC payment service which supports Testnet payments, or will I just have to roll with BTC?
As an extra question (sorry for off-topic) can someone recommend such services for processing Ripple payments?
Thank you in advance. Let me know if I can give any more info that would be helpful.

please do not use blockchain.info if you're gonna test payments.
use block.io instead, it has a full documentation for devs to try it.
you can use Testnet BTCs HERE


text:
Is the hash of the coinbase transaction needed for the merkle root?
first time posting here.
I was interested on how mining software works down to the bytes. I came across this well written article right here:
http://www.righto.com/2014/02/bitcoin-mining-hard-way-algorithms.html
Under "Notes and References", he provides a python program that generates the merkle root from a list of transaction hashes. What I don't understand however is, why or how the hash of the coinbase transaction is included in that list.
Lets say you are in the process of mining a new block. You make your list of transaction hashes(without the coinbase transaction, as you haven't mined the block), create the merkle root and guess the nonce until you create a block. Now the coinbase transaction takes place and you get your bitcoins, the coinbase transaction hash now has to be included in the list of transaction hashes. But that changes the merkle root and thus the entire block, which would make it unvalid.
How is this solved? Do you know the hash of the coinbase transaction in advance? Or do you not include the coinbase transaction for the new block and the python code is not correct?
Also a side question is, in the python code this part confuses me a bit:
 h = hashlib.sha256(hashlib.sha256(a1+b1).digest()).digest()

Does a1+b1 mean that you perform addition of the hash values or that you just append the two hashes together?
Thanks in advance,
Fihdi

You make your list of transaction hashes(without the coinbase transaction, as you haven't mined the block),

This is where the problem in your understanding lies. The coinbase transaction is generated before the block is mined, not afterwards, because it must be included in the list of transactions just like all the others. It is the first transaction in the block, and its hash is used in exactly the same way as all the others when constructing the merkle root.
Once the coinbase transaction is created and the merkle root calculated, then the nonce is varied and the block is mined.

Does a1+b1 mean that you perform addition of the hash values or that you just append the two hashes together?

Append the hashes, not add them

This is correct. Benefits of this approach includes that the coinbase transaction cannot be altered after a block with a "correct" blockheaderhash is submitted, which for example could manipulate the mining reward the miner receives. Another benefit is that this allows the miner to add an extra nonce inside the coinbase transaction. This is very beneficial as the possible different combinations of values in the 4 byte nonce in the blockheader is too small for modern miners which exhaust all different combinations in less than one second (and the timestamp field in the blockheader changes).


text:
Running full node ( bitcoind ) without private key
I want to run full Bitcoin node ( via bitcoind ) in a "secured listen-only" fashion, ie if anybody gets access to the server he gets nothing.
At the same time I want to be able to execute RPC calls such as:
- listtransactions  ( to get transactions for my specific wallet )
- gettransaction
Is it possible? If yes, how to achieve this?
No sending should be possible from my wallet, of course.
I assume that using a key -disablewallet won't allow me to use listtransactions rpc call.
Thanks

You can simply add your addresses as "watch only" addresses to the wallet, which means that the private keys are not stored on the server, but the transactions are still listed by the RPC calls. You can then keep your private keys elsewhere, for example on a hardware wallet.

ok, but how exactly to do it? what rpc call to use / what change in the config / what parameter in command line for bitcoind?
Will definitely look by myself right now, but if you already know it, please tell me..

Use the importaddress RPC, so it never sees the private key

Hah..Thanks...
I was checking outdated API:
https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

Will try out :) Hope everything will work..


text:
Is it secure to put a wallet address on one's business cards as a QR code?
As a company, we're making business cards, and would like to put our bitcoin addresses on our business cards as QR codes. Yet, I know that it is a best practice for wallets to cycle addresses - I mean, after an address is used, then create another one. So, is it safe to put wallet address QR codes on multiple business cards and distribute them, and are there best practices for doing so? What security benefits does one lose by distributing the same receiving address to all clients and associates, or would it be wiser to pre-generate a few dozen each time we generate our QR codes to print business cards, so that they can all be unique? Would that even be possible, without using each one once before the next is generated?

that's not a bad idea in regards of doing business and distributing it to people. however, as far as I know, a single address is fine because the address itself is secured. the security flaw of a single address distributed will be - people can check the addresses on how good your business is doing. hehe. correct me if I'm wrong. Wishing you all the luck with your business.

Could you please link to any more canonical sources written about this topic? As it concerns security, I would like to rely on a more comprehensively written source.


text:
How many wallets don't support address reuse? (for refunds)
I have implemented an automated bitcoin refund function that sends funds back to the address that was used to sign the incoming transaction.  How many wallets fail to support address reuse/refunds?  If it's just a few wallets or only shared e-wallets then I am content with a notice on my site explaining the situation.
Responses to common objections (i.e. rant)

There is no "from address"

Yet each incoming transaction has its own list of incoming transactions with its own outputs sent to various "destination addresses", therefore the notion of their being no "from address" is not valid.  (note I'm not concerned with uncommon transactions such as coinbase transactions which truly can't be refunded automatically...  I am content to handle refunds for these uncommon transactions on a manual basis if needed.)

address reuse hurts privacy

What privacy?  Bitcoin doesn't provide any privacy... the transaction graph is open to the public and your silly if you think social graph networking algorithms can't link these transactions together with high probability.  if you wan't privacy use a mixing service... if you can't then there is very little privacy for your transaction.

address reuse is not secure

Bad implementation does not equal bad security protocol.  Just because a few wallets used to implement cryptographic algorithms incorrectly doesn't mean I should forever believe that the same cryptographic protocol is insecure for wallets that are correctly designed.

addresses are intended for one-time use

really? then why are donation addresses valid for years???

I think it would be helpful for you to identify your service here, so that I can encourage people to not do business with you.
Users generally have no idea if this will work safely or not, so a notice will not be sufficient. If you send users funds to addresses they did not supply you should be prepared to pay them out when they report the funds have gone missing or find yourself on the losing side of a lawsuit-- and there would be no shortages of experts willing to testify on behalf of someone you failed to pay due to this.

Yet each incoming transaction has its own list of incoming transactions with its own outputs sent to various "destination addresses", therefore the notion of their being no "from address" is not valid.

Sorry, that simply is not correct.
Coins have a history from which you could derive prior "To" addresses, that much is correct. But a prior "To" is not a "from".  For example,  if you ordered a produce from amazon, received it, then inspect the parcel with a magic wand that told you the last place the parcel was shipped you might find it was last sent to a reshipment center in Oregon.  But that is just some shipper, not the source (amazon) and if you attempted to "return" the package by simply shipping it there it would likely end up lost.
Your order "from" amazon may have gone through dozens of steps or indirection before reaching you, and the last hop may have only the thinnest of relationships to the actual origin.
Even if the "from" is correct the user may simply no longer have access to the keys. With no more use for them they simply may have discarded them (e.g. a 'paper wallet' or other token). Users can setup persistent donation addresses intentionally taking due care to preserve the key material, and for donations the security/privacy implications are reduced because of the very nature of the payments (the donation addresses are public and the funds aren't provided in exchange for any consideration). And when access isn't lost completely, the keys in question may not be readily accessible, but stored in a safe deposit box or time lock safe.  The funds could have also been spliced out of a payment channel and the prior-to could be inaccessible to the user without significant software modification or the help of a third party.

What privacy? Bitcoin doesn't provide any privacy...

Bitcoin does provide privacy and has since day one. It is specifically called out as a top level section in the Bitcoin whitepaper. The privacy Bitcoin provides isn't perfect for sure, but one of the biggest things that damages privacy is address reuse because it creates co-input linkage, causing otherwise completely independent spends to be obviously linked.  Mixing "services" are frequently scams that steal user funds.
Your self-described "rant" seems to have also ignored the largest practical consideration: A great many wallets (perhaps the largest in total user count) are thoroughly incompatible with your intended behavior.  If a user pays you from a hosted wallet and you "refund" to one of the apparent prior-to addresses, the funds will be delivered to some other random user (who will probably promptly withdraw their windfall, never to be heard from again).

your amazon analogy is incorrect because the intermediate shipping facility has no claim of exclusive ownership over the shipment.  Exclusive ownership rights are first owned by amazon, and then the customer, from->to, a direct ownership transfer.  The bitcoin white paper states that coins [are] made from digital signatures, which provides strong control of ownership the digital signature provides the EXCLUSIVE ownership rights.

a notice will not be sufficient, I was not aware of this... are you saying that satoshidice.com is at risk of lawsuits from any customer who fails to understand their
notice IMPORTANT: Only use wallets that allow you to receive Bitcoin from the same address you sent from. ???

the user may simply no longer have access to the keys which is the their wallets fault (I would be doing immediate refunds), therefore I ask the question "how many wallets fail to support address reuse?".

the funds will be delivered to some other random user which I reiterate probably violates the white papers statement that digital signatures [provide] strong control of ownership and so unexpectedly transferring ownership of a private-key in my opinion violates this principle.

Reviewing your answer and my comments, I have to ask... Why did you even post an answer?  Your answer does not even address the question... in fact it ignores the bulk of the question...

Since no one else answered I ended up offering the customer the ability to specify an automatic refund address, it was a waist of time, but without knowledge of how many clients are defective I had to resort to the worst possible implementation to pander to incompetent bitcoin wallet developers.  Thanks for nothing.

Since I no longer care about an answer, I will be deleting this question.  Again, thanks for nothing.  You wasted my time, congratulations!

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


text:
i have lost 83$ worth bitcoin from my blockchain wallet can any one help me to recover it?
on 2018 oct 19 there was a transaction which I haven't done from my wallet of 83$ bitcoin please help me to get it back

Bitcoin transactions are generally not reversible.  If this transaction has been confirmed, your coins are gone.
If you think the transaction was erroneous, you can contact customer support for your wallet provider.  If they discover that it was due to a bug in their system, they might reimburse your money.
Unfortunately, a common cause of such loss is that someone compromised your account, e.g. by guessing your passwords, or by hacking a computer that you used to log in to that account.  If this is the case, it's unlikely that you will be reimbursed, and all you can do is plan to improve your security in the future.
In either case, it would be unwise to use this wallet ever again.  If there are still funds there, transfer them immediately to a different wallet; ideally, one created using a freshly installed operating system on a secure computer.


text:
Hiding identity in digital currency era
I have a question about the security of digital currencies, however still I have find a clear answer for that. No matter what is the currency, e.g bitcoin, monero, ..., at the end of the day, I have to go to somewhere and change the digital money to physical money. Isn't that?
For example, I have 20 XMR. I need to change that to Dollar. So, I have to tell somebody (a bank or someone else) to take this 20 XMR and give me some money. At this point the identity is revealed.
Specifically, I have to first transfer the digital money to the person in the other side and then take the physical money.
Can someone explain that?

You could exchange p2p without revealing your identity

Can you explain more? Any reference?

I have to go to somewhere and change the digital money to physical money.

Although that is the current reality, with a few exceptions, it is not the vision of how cryptocurrencies would work.
The intent is that everyone globally would accept your cryptocurrency directly without any need to convert to or from other currencies.
We can see that the Euro has replaced lots of national fiat currencies in the Eurozone. The dream of cryptocurrency promoters is that at least one cryptocurrency will become globally pervasive to the extent that you never need any fiat currency.

If you go through more or less official trading sites or exchanges, you will first have to reveal your identity.
There are however sites like "localbitcoins.com", which allow to find people in your region, to exchange money without delivering details on your identy. This is what @Raghav put in his comment. You may also want to visit bitcoin meetups, another possibility to meet crypto ccy friends, and find some people willing to get you started.


text:
Where is the code of chain reorganization in Bitcoin Core
I'm trying to understand how Bitcoin Core works in-depth. Can someone tell me where is the code executed during a blockchain reorganization in Bitcoin Core?
Any explanation would also be greatly appreciated.

Possible duplicate of Where in Bitcoin Core does it do X?

When you say reorganization, do you mean a spontaneous fork in the blockchain? or are you referring to the suggestion of Binance recently after their hack, to “reorganize” and rollback the blockchain, and you are wondereing if there is code in place to do the reorg of the blockchain? (spoiler alert: there isn’t any).

@bitcoinero I mean spontaneous fork. How the best chain is selected.

Block tree is stored on-disk. During startup, is read into memory. When read, BlockManager::m_block_index field is filled with data - CBlockIndexes. Every CBlockIndex contains memory-only field arith_uint256 nChainWork, which is a total amount of work in the chain up to (and including) current block.
Best chain is selected as maximum among all nChainWork of all tips and saved to CChainState::m_chain - currently active chain.


text:
Where is the New button in the Receiving Addresses windows of bitcoin core 0.17.0?
I'm not imaging this right - the New button in Receiving Addresses of bitcore core has just disappeared in 0.17.0?

Press "request payment" to get an address.
The button on the address book was redundant and was removed by PR12721.


text:
How to use Interfaces inside a contract?
How can I create and use Interfaces inside a contract?
For example when I have the following contract:
package com.jelurida.ardor.contracts;

import nxt.addons.AbstractContract;
import nxt.addons.JO;
import nxt.addons.RequestContext;

public class TestContract extends AbstractContract {

    public interface Test {
        String addPrefix(String text);
    }

    public class TestImpl implements Test {
        @Override
        public String addPrefix(String text) {
            return "prefix_" + text;
        }
    }

    @Override
    public JO processRequest(RequestContext context) {
        Test test = new TestImpl();
        JO resp = new JO();
        resp.put("text", test.addPrefix("some text"));
        return context.generateResponse(resp);
    }
}

I get the following error while running unit tests:
2018-12-20 17:40:09 INFO: main Loading resource from com/jelurida/ardor/contracts/TestContract.class
2018-12-20 17:40:09 INFO: main Loading resource from classpath com/jelurida/ardor/contracts/TestContract.class
2018-12-20 17:40:09 INFO: main Loading inner class com.jelurida.ardor.contracts.TestContract.TestImpl resource from com/jelurida/ardor/contracts/TestContract$TestImpl.class
2018-12-20 17:40:09 INFO: main Loading resource from classpath com/jelurida/ardor/contracts/TestContract$TestImpl.class
2018-12-20 17:40:09 INFO: main Loading inner class com.jelurida.ardor.contracts.TestContract.Test resource from com/jelurida/ardor/contracts/TestContract$Test.class
2018-12-20 17:40:09 INFO: main Loading resource from classpath com/jelurida/ardor/contracts/TestContract$Test.class

2018-12-20 17:40:09 INFO: main Shutting down...

java.lang.LinkageError: loader (instance of  nxt/addons/ContractLoader$CloudDataClassLoader): attempted  duplicate class definition for name: "com/jelurida/ardor/contracts/TestContract$Test"

    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at nxt.addons.ContractLoader$CloudDataClassLoader.findClass(ContractLoader.java:308)
    at nxt.addons.ContractLoader.loadContractFromJar(ContractLoader.java:252)
    at nxt.addons.ContractLoader.loadContractFromJar(ContractLoader.java:210)
    at nxt.tools.ContractManager.loadContract(ContractManager.java:437)
    at nxt.tools.ContractManager.uploadImpl(ContractManager.java:327)
    at com.jelurida.ardor.contracts.ContractTestHelper.lambda$deployContract$0(ContractTestHelper.java:110)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.jelurida.ardor.contracts.ContractTestHelper.deployContract(ContractTestHelper.java:107)
    at com.jelurida.ardor.contracts.ContractTestHelper.deployContract(ContractTestHelper.java:98)
    at com.jelurida.ardor.contracts.ContractTestHelper.deployContract(ContractTestHelper.java:93)
    at com.jelurida.ardor.contracts.ContractTestHelper.deployContract(ContractTestHelper.java:89)
    at com.jelurida.ardor.contracts.TestContractTest.uploadTest(TestContractTest.java:9)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runners.Suite.runChild(Suite.java:127)
    at org.junit.runners.Suite.runChild(Suite.java:26)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

How can I solve this error?
I'm using version 2.2.1

I assume that the problem here is that Test interface is being loaded twice, first when the contract is being scanned for inner classes to load then indirectly when the TestImpl class is loaded and this is causing the "attempted  duplicate class definition for name: "com/jelurida/ardor/contracts/TestContract$Test" error.
It is probably something we can fix for the next release.

That would be really really nice and helpful. FYI the same error occurs when you move the Test interface and TestImpl class from inner classes to "normal" classes where everyone has their own file

In the next release we'll simply prevent a class from being loaded twice by the cloud data class loader.


text:
What is the mechanism to ensure execution of contract parameters specified in a contract reference transaction?
If it is allowed to specify contract parameters within the contract reference transaction, it should be possible to adapt the HelloWorld example contract to send a message to an account specified in the reference transaction.
For example, when I send a trigger transaction from account A to the contract runner account B, the contract responses with a message to Account C (where account C is specified in the reference transaction).
What if there is another reference transaction that specifies an account D? How can I be sure that the response will be sent to account C? Is there a parameter for the trigger transaction to reference a specific contract reference transaction?

The trigger transaction only specifies the contract reference name. This contract reference name is unique per account. It is possible for a different contract runner to use different contract runner account with different contract reference names. Which means that the same trigger transaction can trigger different runners to load and run a different version of a contract from the blockchain or even a completely different contract depending on the reference.
Having said that, a trigger transaction most likely will set its recipient to a specific account, triggered contracts should first check if they are the recipient of the trigger transaction and ignore it if they are not.
There could be variations on this, for example a contract can choose to process a trigger  transaction for which its contract runner account is not the recipient. Perhaps the contract runner account has set specific account properties on a group of accounts it would like to consider when they are a recipients of a trigger transaction.
Having said that, in most cases I expect that only one contract runner will process a trigger transaction and the rest will ignore it.


text:
proof of stake concept and implementation confusion
i'm currently studying proof of stake concept in cryptocurrency in preparation of building it soon, but i still have some doubts about my understanding of the concept itself, and i have a lot of questions about it.
IF i set the max supply of 21 millions coins, question is :

do i have to premine all the coins (21 millions of them) and put it in the programs's wallet? or just let it not mined at first, and release the coins when the forger have solved a block?
do i have to build an offline wallet (windows, mac, linux os) or is an online web wallet will be enough for POS staking?
about the POS itself, lets say for example there are 100 stakers, with various amount/percentage of coins staked, i understand they're given interest lets say for example 5% a year on their staked coins, which stakers will given a block to solve the hashing problem? will it be random based on their percentage of stakes? will the comission of solving the block go to the solver (1 staker) or go to all of the stakers by percentage of their stake percentage (100 stakers).
according to What is proof-of-stake? it was said that someone possessing 1% of the total stakes "mine" 1% of the total blocks, it gets confusing here, if example 1 block contains 100 transaction, so this 1% stakers will be solving hash of 1 transaction? is this correct?

Your first three questions are questions about what you want to do. We have no way to know what you want to do. Your fourth question is technical:

according to What is proof-of-stake? it was said that someone possessing 1% of the total stakes "mine" 1% of the total blocks, it gets confusing here, if example 1 block contains 100 transaction, so this 1% stakers will be solving hash of 1 transaction? is this correct?

No. A staker who holds 1% of the stake will mine 1% of the blocks. That means one out of 100 blocks will, on average, be mined by them. That block can contain 100 transactions or no transactions, that staker would typically have free choice of what to put in the blocks they produce.

i believe my first 3 questions IS NOT WHAT I WANT TO DO, i believe i'm asking people WHAT I SHOULD DO. let me rephrase the question to make this clear : 1. "DO I HAVE TO" premine all the coins (21 millions of them) and put it in the programs's wallet OR DO I HAVE TO or just let it not mined at first, and release the coins when the forger have solved a block? WHICH SHOULD I DO? i believe that's not asking WHAT I WANT TO DO. same goes with point 2 and 3 on my questions list.

for point number 4, about your answer, lets say if a blockchains contain 10 blocks, with 10 transactions inside, the staker have only 1% of stake, how many blocks will he mine? and also you're saying staker could CHOOSE what to put in the blocks? what do you mean by this?

@HandyWijaya If he has 1% of the stake, on average he will mine 1% of the blocks. Just like a person who buys 1% of all lottery tickets sold will on average win 1% of the prizes. Yes, in most schemes, each miner/staker gets to choose what to put in the blocks they mine.

i still don't get detailed enough. example in MYCOIN i have a blockchain with 10 blocks in it, inside each blocks it has 10 transactions in it. so the 1% stakers with get to mine 1% x 10 blocks = 0,1 block? or no block at all due to 0,1 block not 1 full block? but if he gets to mine 1 block, lets say he choose the last block (the 10th block), it means he has to wait for the other previous 9 blocks to be mined first then he gets to mine that 1 last block? sorry for the more detailed question, but i have a very deep confusion on this topic.

@HandyWijaya For any given block, a person who has 1% of the staking of the people who are trying to make a block at that time has a 1% chance of making that particular block. It's just like a lottery. For each drawing, a person who has 1% of the tickets has a 1% chance of winning. If he's waiting for something, he has 0 chance. Only those trying to mine a block can mine a block. If he's trying, his chance of succeeding is in proportion to how much of the stake of those trying is his. In most schemes, each block is independent.

okay, i understand now, after many confusing reading on google plus your helpful answer, i can summarize that in POS, it's just a matter of luck like a lottery, people who only investing of total 1% of stake may not be mining a block due to only 1% of chance ya? i think this POS scheme isn't fair for the whole investor, i'm gonna implement my own POS system now which guarantee all investors big and small have their earnings even with just 1% of stake. THANK YOU VERY MUCH David.

@HandyWijaya You will have a very hard time designing such a system as there are numerous unsolved problems you will have to solve. If we all know, per the rules, that a particular person must generate the next block, what happens if they don't? Will the system just halt? How will a consensus form on when to give up waiting? (Make sure you develop a very detailed understanding of the problem you're trying to solve before you start proposing novel solutions to it! The primary problem is how to deal with numerous hostile participants and relying on one of them is bad.)


text:
What does PreviousTxnID refer to in Ripple API?
What does the field PreviousTxnID refer to? Does it refer to the most recent transaction? Not sure what it specifically means. Help would be appreciated.

The PreviousTxnID field has two uses. One is in transactions, is deprecated, and should never be used. So let's forget about that.
The other one is in ledger entries. The PreviousTxnID field appears in ledger entries, along with the PreviousTxnLgrSeq field, that are "threaded". Threaded ledger entries maintain a thread of transactions that affected them to allow their state to be walked backwards.
So, for example, say you look at an Offer ledger entry. You will see PreviousTxnID and previousTxnLgrSeq fields that identify the ID and ledger sequence number of the last transaction to affect that entry. If you look at the metadata for that transaction, you will find out how that transaction affected this ledger entry and you will get the old values of these fields. With the old values, you can walk the thread back to the previous transaction and so on to see the history of the ledger entry.
When an Offer entry is removed, it is threaded to the AccountRoot of its owner. This prevents the thread from being lost and allows you to walk an AccountRoots thread to find all the Offers it owned.
This was a very early feature added to the ledger in 2012 and was intended to make it easier for light clients to walk the ledger's transaction history without having to trust a server.


text:
How to paginate through api?
I have looked at the following link:https://dashblockexplorer.com/api/txs/?block=990001, and I am wondering how to paginate. You may notice that pageTotal is equal to 5.

I'm voting to close this question as off-topic because it is not about Bitcoin.

From its api info page, dashblockexplorer.com uses insigth api, and so just append to the url:

&pageNum=#

For example, for the next page (#1, as it starts on zero):

https://dashblockexplorer.com/api/txs/?block=990001&pageNum=1

Last page should be pageNum = pagesTotal-1


text:
How do you download blockchain data (transactions etc.) using a node? Best ways to get a node?
I am just curious how one can download bitcoin data and blockchain using a node. Where should I start?

I am just curious how one can download bitcoin data and blockchain using a node

One way is to download and install a full-node desktop wallet such as Bitcoin-core.
When it is first started it will download the full blockchain. This may take a week - depending on your Internet-connection's bandwidth.

Where should I start?

https://bitcoin.org/en/ is probably a reasonable place to start.
Ask questions here (one at a time) about any problems understanding or using Bitcoin. But use the search function here first - lots of great answers already exist for many problems.


text:
Why is input number non-existent in bitcoin API?
Why when I use this public Bitcoin Api to practice a command, the input value of BTC does not show up?
API Call can be found here:
API Website
Transaction from block explorer can be found here:
Explorer Tx
{
    "result": {
        "txid": "1e12864a9852ebd2b71a743752cc1561b000663f47bd71bc383b0cacad614d86",
        "hash": "bf43137e355def3d6292c296c864d9f6a9da353db6e4bd40c55e7cc4df245774",
        "version": 2,
        "size": 249,
        "vsize": 168,
        "locktime": 0,
        "vin": [
            {
                "txid": "9de8923855b2c56bc903c39418298fa8c185e5feb99cb32bfa31b9d06700ced8",
                "vout": 1,
                "scriptSig": {
                    "asm": "00140b67d98b0069797e0b5c94964f94d69476bea509",
                    "hex": "1600140b67d98b0069797e0b5c94964f94d69476bea509"
                },
                "txinwitness": [
                    "30440220625b6fd7299cfd14e6bdaa63cef809da54d4016c6caf5d268fc80c48d7fb41cc02200da35a319d63926112aa26952933ce590e67023993072ab10ab2bfb44f55704f01",
                    "03c97015da537daded1ac5fd4b5f9cfe55d1d77aed63da77da097d2af087361339"
                ],
                "sequence": 4294967295
            }
        ],
        "vout": [
            {
                "value": 1.99550000,
                "n": 0,
                "scriptPubKey": {
                    "asm": "OP_DUP OP_HASH160 b0fe30da6628923202cbf6e877405ea6d484e9eb OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914b0fe30da6628923202cbf6e877405ea6d484e9eb88ac",
                    "reqSigs": 1,
                    "type": "pubkeyhash",
                    "addresses": [
                        "1H8rSFYmaZoSbdsXjF4Q5zb53FHNYAdTLj"
                    ]
                }
            },
            {
                "value": 82.88960000,
                "n": 1,
                "scriptPubKey": {
                    "asm": "OP_HASH160 fe7dfeeb1cbf6330590bc7ee2c47a2de593f1920 OP_EQUAL",
                    "hex": "a914fe7dfeeb1cbf6330590bc7ee2c47a2de593f192087",
                    "reqSigs": 1,
                    "type": "scripthash",
                    "addresses": [
                        "3QteVcFbTqoS8fSFYgwuet1yWD8YGfuas4"
                    ]
                }
            }
        ],
        "hex": "02000000000101d8ce0067d0b931fa2bb39cb9fee585c1a88f291894c303c96bc5b2553892e89d01000000171600140b67d98b0069797e0b5c94964f94d69476bea509ffffffff0230e4e40b000000001976a914b0fe30da6628923202cbf6e877405ea6d484e9eb88ac007e0fee0100000017a914fe7dfeeb1cbf6330590bc7ee2c47a2de593f192087024730440220625b6fd7299cfd14e6bdaa63cef809da54d4016c6caf5d268fc80c48d7fb41cc02200da35a319d63926112aa26952933ce590e67023993072ab10ab2bfb44f55704f012103c97015da537daded1ac5fd4b5f9cfe55d1d77aed63da77da097d2af08736133900000000",
        "blockhash": "0000000000000000000dfeca4aac6372aa5aff5beb3bd13105eedb2269375723",
        "confirmations": 103,
        "time": 1541981822,
        "blocktime": 1541981822
    },
    "error": null,
    "id": null
}

That is how it works, you need to look up the previous transaction where that output exists in order to get the value. The equivalent call using bitcoin-cli is:
$ bitcoin-cli getrawtransaction 9de8923855b2c56bc903c39418298fa8c185e5feb99cb32bfa31b9d06700ced8 2

then you can find the vout with index 1.

Great, and thanks. @JBaczuk do you know of a way to implement a python script to do this for all transactions.

NP, that's a pretty broad question are you asking me to code it for you? You can call that RPC endpoint using http and then parse the results. There are plenty of python wrapper modules out there for bitcoin-core RPC.

great. yeah it is a broad question but just want to make sure its possible. Do you know of any helpful links? Not asking you to code it.

I'd just search for python bitcoin rpc, i haven't personally used any of them myself.


text:
How do you set txindex to 1?
I am using bitcoin.rpc.RawProxy to connect to bitcoind and scrape the data. But I am getting an error when I gettransaction and I have to reindex the blockchain. Thus I am wondering how I set the txindex to 1 so I can reindex and continue.

You can enable the txindex by either adding it to your bitcoin.conf file:
txindex=1

or
You can run bitcoind with the -txindex flag:
$ bitcoind -txindex

See:
$ bitcoind --help

    -txindex
       Maintain a full transaction index, used by the getrawtransaction rpc
       call (default: 0)

but reindexing is necessary correct?

Yes you might need to also use the -reindex flag. You might also want to set a higher -dbcache to speed it up.

One more question, and thanks again. If I do not shut out of the ubuntu command prompt correctly, for example if I have to restart it or if it shuts down unexpectedly, can it corrupt the data?

And will I know if the database is corrupted? For example, will the program notify me?

If you set the -daemon flag it will run in the background and you can close the terminal. If it shuts down, it may corrupt the data, but you should see errors in ~/.bitcoin/debug.log

would I have to run the file debug.log or just click into it? Basically how would I tell?

it is a text file, but I think the application will crash if the data is corrupted. Either way, you can watch the log file with $ tail -f ~/.bitcoin/debug.log


text:
Bitcoin Tranaction can one trace in coming transaction to receiving wallet
I know you can trace a bitcoin trans,from where it left from and where it is on the block chain ...
my question, "i was reading".... is it possible to trace a INCOMING transactions to ones receiving wallet address
i am new not sure if this is in the right area just a web link and a how do you do would be much appreciated
Comrade

is it possible to trace a INCOMING transactions to ones receiving
  wallet address?

not sure what is meant by incoming transaction in this case. But generally yes, it doesn't matter if transaction is incoming or outgoing. I assume this scenario: a transaction from Alice is made to Bob. Alice creates the transaction, and she refers to it as outgoing transaction, Bob sees it as incoming transaction.
So Alice creates let's say a standard P2PKH transaction, and in there one can see two sections: one from where to take the funds (the incoming part), and one where the funds shall go (the outgoing part). One can find references to the pubkeys in both parts. And these pubkeys can be used to decode into addresses.
Example:
In one of my transactions, I had this code in the input section (TX_IN Script Sig):
...4730440220128487F04A591C43D7A6556FFF9158999B46D6119C1A4D4CF1F5D0AC1DD57A94022061556761E9E1B1E656C0A70AA7B3E83454CD61662DF61EBDC31E43196B5E0C10012102B12126A716CE7BBB84703BCFBF0AFA80283C75A7304A48CD311A5027EFD906C2...

which translates into:
47 --> push hex 47 (decimal 71) bytes on stack (usually the DER encoded signature)
       30 44 02 20 128487F04A591C43D7A6556FFF9158999B46D6119C1A4D4CF1F5D0AC1DD57A94
             02 20 61556761E9E1B1E656C0A70AA7B3E83454CD61662DF61EBDC31E43196B5E0C10
01 --> SIGHASHALL: this terminates the ECDSA signature
21 --> push hex 21 (decimal 33) bytes on stack (length of a compressed Public Key)
       02B12126A716CE7BBB84703BCFBF0AFA80283C75A7304A48CD311A5027EFD906C2
       corresponding bitcoin address is: 18KHdtRfkv4GaBidjNpNEQkpPwfXC39M9W

and this in the output section:
...90257300000000001976A914FCA68658B537382E27A85522D292E1AD9543FE0488AC...

which translates into:
9025730000000000 --> TX_OUT Value (hex 9025730000000000 is 0.07546256 in bitcoin)
19               --> TX_OUT PK_Script Length
76A914FCA68658B537382E27A85522D292E1AD9543FE0488AC --> the P2PKH Script:
    76: OP_DUP
    A9: OP_HASH160
    14: OP_Data14 (= decimal 20)
        FCA68658B537382E:27A85522D292E1AD:9543FE04
    88: OP_EQUALVERIFY
    AC: OP_CHECKSIG
  This is a P2PKH script to this address:
   FCA68658B537382E27A85522D292E1AD9543FE04
  and translates base58 encoded into this bitcoin address:
   1Q2tmgphDqFJxhFFYNrjBr5o8XKSSDKtXv

Summary: a transaction contains inputs and outputs, and with standard P2PKH transactions you can derive the addresses, from where to where funds move. For Bob having it as incoming transaction, one can trace the funds, where they came from.
The details of how transactions are assembled, how public keys are used, and how you can derive the corresponding addresses are explained in the bitcoin developer section documentation, and a good playground to get conversions between both is on TP's Go Bitcoin Tests. Oh, and of course I should mention Andreas' book "Mastering Bitcoin" as an amazing book. It's freely available online.

Well many thanks for taking the trouble and time to help me its a bit tech apart from Alice and Bob but i am computer lit and understand the basic i will get more familiar ...why i pose the question as you know there are unscrupliaias people out there so i wanted to know is the send to me i can confirm that the are telling the truth via the my wallet address being active at that point to take a transaction and so i can rest assured the trans and amount are correct

OK. Assume you have the original bitcoin client wallet, or Electrum (no "online" wallet): at that point you provide one of your wallet addresses (there are many generated at startup of the wallet software) to "them", they send bitcoins to this address, and when the first confirmation is received (aka your tx is included in a block), you can be assured amount arrived. For higher amounts its better to wait 6 confirmations. This is the way bitcoin is designed. Addresses cannot be active or inactive - if you are told such stuff, it is most probably a scam.

Thanks Thanks thanks for your answer .. i am understanding it better Nice one for getting back to me


text:
Someone want to mine with my bitcoin (www.elitecoinmine.com) Promises?
I just signed up to ask this Question. Shoort story about me: I don't know much about crypto currency, just spend 50Eur once to buy some Dash.
Anyway, there's a guy writing me via my instagram and then via whatsapp since almost a year, he always ask me to buy Bitcoin (about 150$ at least) and he will be my manager and www.elitecoinmine.com will be using my bc to mine, and he talks about very fast profit (in about 48 hours).
So I asked one of my close friends who is more into crpyto currency and he was lauginh about it, like "How can someone mine with your bc, thats rediculious".
Now I want to ask you guys, is it even possible that someone mine with my bc?? or is this a bad joke at all, i can see that i might rent some equipment to do mining, which i would never do, but using my bc to mine??
He always talks about that they work with antminers S9 (whatever that means)
and yes it's all about www.elitecoinmine.com, if someone got some expirience please let me know, i'm very puzzled since I don't know that much about it.
Thanks in advance

This is a scam.  Block all contact with this person and do not send any money, passwords, keys, or anything else.
Your friend is right, there is no such thing as mining "with" somebody's Bitcoin.  Mining requires specialized hardware (such as the AntMiner S9, which is a real device) but if one has that hardware, one doesn't need access to additional coins or anything else.
The scam will probably be organized in a way that it looks like you keep control of the coins throughout the process, and such that it is not obvious that your coins have been transferred to the scammer.  But in the end, when you try to get them back, you will find that you can't.


text:
My app doesn't work after an update

My app doesn't work, it seems all white and doesn't show anything. It doesn't let me do anything and I'm so worry because I have a few bitcoins in my wallet. What should I do to solve my situation?. I hope you help me to solve it

Contact the developer of the app. This is an issue for their customer support.

See https://mycelium-support.zendesk.com/hc/en-us/articles/115003713712-How-do-I-restore-a-backup-


text:
logic behind bitcoin exchange
Im currently working on exchange program. Just a problem during exchange process. An example, we have an SELLING LIST which list down all trading and selling of bit coin. So, in the meantime, there will be a tons of buyers to see the most appropriate and cheap sales. Give an example that there is one items from the Selling List that selling 1BTC for 1USD, so every buyer will immediately click on the item to buy the item. Hence, the question and issue is here,
Is there any effective way to tackle our program to avoid from crash as caused from multiple user clicked and accessed the item on the same?
I'm thinking about FIFO on the user access. Is there any more efficient way to tackle this issue?

If you need to ask random strangers on the internet how to build your business, you have a problem.

this question has nothing to do with bitcoin. I would strong suggest you to post it on stackoverflow after you show what you have tried to do thus far. You're looking for a system-design.


text:
How to perform CPU mining on bitcoin TESTNET on Linux?
I need approximately 100 Bitcoin Testnet to run an experiment on the lightning network.
Any suggestion on how to run CPU mining? Should I use cgminer?
Make any sense to perform solo mining on testnet?
Currently I am running a full testnet node with bitcoind on a linux environment.

Maybe you can find a faucet? Here is an older but probably still appropriate answer: https://bitcoin.stackexchange.com/questions/29791/how-can-i-do-cpu-mining-on-testnet

You will have to wait until the difficulty is reset to 1, and even then, you might not be able to win a block with the flood of other blocks coming in.

It's possible to mine Testnet BTC with CPU (even with the basic generatetoaddress command), because testnet difficulty drops significantly when there are no blocks on the network for 20 minutes:
bitcoin-cli generatetoaddress nblocks "address" ( maxtries )

If you want to continuously mine on Linux, create a bash loop:
while [ 1 ]
do
    bitcoin-cli generatetoaddress 1 "2N5fJkfCv4cF6vsa5QQJnsazBKWNXynn9zp" 10000000
done

Your luck will depend on other miners activity, for example I was able to mine 6 blocks in 2.5 months.

'generate' methods are only effective on Regtest, where you can create blocks at will.
Testnet works like Mainnet (although with lower difficulty), so you need proper mining equipment to generate a block.

You can mine with this command, like I did, check my testnet BTC address: https://blockstream.info/testnet/address/2N5fJkfCv4cF6vsa5QQJnsazBKWNXynn9zp
This is possible because the difficulty drops to 1 on testnet if there is no new block after 20 minutes.


text:
Which daemon is a lightning node running?
To run a lightning node we can use 3 different daemons :
 - c-lightning
 - eclair
 - LND
Is there a way to understand which daemon is a specific peer running?

By the lightning network protocol there is no direct means to detect which implementation is used by another node.
However you could use indirect hints for example the standard cltv deltas or channel fees are different for the various implementations. That being said I could obviously run clightning with the default config of lnd.
Even if there was a way (like the user-agent header of http) nodes could easily spoof such a header.
On a side note: just to be clear there is currently a forth implementation that is said to be mainnet ready called Ptarmigan. Also electrum is short of being ready for mainnet.


text:
How to obtain the Channel_ID from the Short_Channel_ID?
Is there a way to retrieve the Channel_ID knowing the Short_Channel_ID without using any lightning network explorer?
How is the Short_Channel_ID calculated? Is this operation reversible?

The short_channel_id points to the funding transaction of the payment channel by the format blockheight x transaction_index x output where the x is used to separate the three values, and the three values are depicted in decimal. This is at least the BOLT 1.1 agreed format for the short channel id. Previously the shortchannel id might have been encoded and depicted differently depending on the implementation. For example, c-lightning used a colon instead of an x to separate these fields.
According to BOLT02 the channel_id is created as follows:

This message introduces the channel_id to identify the channel. It's derived from the funding transaction by combining the funding_txidand thefunding_output_index, using big-endian exclusive-OR (i.e. funding_output_index` alters the last 2 bytes).

As the funding_txid is a hash of its fields, this has no relation with the short channel id. So without looking at the blockchain data, I believe it is impossible transfer the short_channel_id to the channel_id or back.

Thanks Rene for your answer and pointing to the Bolt. It's still unclear to me. A channel id looks something like: "channel_id":"565048921200525312" (a random node token from a recent snapshot). If you XOR a transaction hash and a 2 byte number how could you get a channel id like that one? It's too long to be a 2 byte number and too short to be a number derived from a 32-byte hash.


text:
Schnorr's batch validation
In the recent BIP about Schnorr's standardization, Pieter Wuille presents an algorithm for batch validation. In my understanding the most heavy operation is the multiplication by a scalar: to make batch validation secure we need to multiply each public nonce by a random factor, thus we get back to two multiplications per signature (plus one). I don't understand why there is the speed up presented in the figure at the beginning of the BIP. Could someone help?
Thanks in advance for your answers!

You're right that the elliptic curve multiplication is indeed the most expensive operation in the validation algorithm. And as both single signature validation and batch validation require two EC multiplication per signature, it would seem that no speedup can be gained from batching.
However, several algorithms are known for computing the sum of multiple EC multiplications faster than summing the individual multiplications. Straus's algorithm (also known as Shamir's trick), Bos-Coster's algorithm, and Pippenger's algorithm all provide speedups, and are applicable in different scenarios. In the graph in our BIP draft Straus and Pippenger are used (depending on the size of the batch; Pippenger only wins for batches over ~100 keys). For sufficiently large batches, Bos-Coster and Pippenger are O(log n) times faster than individual multiplications.
To give you an intuition for how this is possible, here is a summary of Bos-Coster's algorithm (while in practice it's not the fastest, it's the easiest to explain):

Start with a list of pairs (a1, P1), (a2, P2), ..., (an, Pn).
Sort this list from large to small ai (and renumber it so that a1 is now the largest number, ...).
While the list has length larger than 1:

Replace the top two elements (a1, P1) and (a2, P2) with the two elements (a1 - a2, P1), (a2, P1 + P2). Note that a1P1 + a2P2 = (a1 - a2)P1 + a2(P1 + P2).
If this results in an element with coefficient 0, remove it (this happens when a1 = a2).
Sort the list again.

When only one element remains, it will be of the form (a, P), where a is the GCD of all inputs. For a sufficiently large n, that GCD will be almost certainly be 1, in which case the solution is just P. Otherwise a will be a small number, and the solution is just aP.

The intuition here is that when you have say 100 multiplications to perform, a1 - a2 will on average be 100 times smaller than the number it replaces (a1), so in every step we're dividing one of the coefficients by 100, while only doing a single EC addition. This is in contrast with naive EC multiplication where you generally need to perform one addition for each bit in the input.

It might be worth mentioning that the final value (a, P), a is the GCD of the inputs, which is why it's usually 1 or small.  It's also the case that you can make an argument for security for randomizer values that are much smaller than the full range-- though this fact isn't necessary for there to be a speedup so maybe it would distract from understanding.


text:
PHP How can I validate / verify a wallet public key?
Can someone please help me find some PHP open source on how to validate / verify a bitcoin wallet public key ? I am currently working on a project  and I am implementing multisig, and it seems I can't find any type of information on how to verify / validate a wallet public key.
Example of public key that I am trying to validate: xpub661MyMwAqRbcEwAAmd9DpSfoDEUar3C2e8LtpeMCaaPWMoLjAf3jY3RucUmtim729c2qzGmYPaBcFdkEUQuwgrFjTKFwEKSCfRfd949k4DC
Basically, I want to make sure the user can't add a wrong or invalid key, otherwise the multisig wallet cannot be created when the system will try to create it, and I need to prevent that
Thank you for your time!

That's not a public key.

BIP32 specifies the serialization format used by extended keys as:

Serialization format Extended public and private keys are serialized
  as follows:

4 byte: version bytes (mainnet: 0x0488B21E public, 0x0488ADE4 private;
  testnet: 0x043587CF public, 0x04358394 private)
1 byte: depth: 0x00 for master nodes, 0x01 for level-1 derived keys,
4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
4 bytes: child number. This is ser32(i) for i in xi = xpar/i, with xi the key being serialized. (0x00000000 if master key)
32 bytes: the chain code
33 bytes: the public key or private key data (serP(K) for public keys,
  0x00 || ser256(k) for private keys)

This 78 byte structure can be
  encoded like other Bitcoin data in Base58, by first adding 32 checksum
  bits (derived from the double SHA-256 checksum), and then converting
  to the Base58 representation. This results in a Base58-encoded string
  of up to 112 characters. Because of the choice of the version bytes,
  the Base58 representation will start with "xprv" or "xpub" on mainnet,
  "tprv" or "tpub" on testnet.
Note that the fingerprint of the parent
  only serves as a fast way to detect parent and child nodes in
  software, and software must be willing to deal with collisions.
  Internally, the full 160-bit identifier could be used.
When importing a serialized extended public key, implementations must
  verify whether the X coordinate in the public key data corresponds to
  a point on the curve. If not, the extended public key is invalid.

Your PHP code must first run the b58check algorithm to verify the xpub is encoded correctly, and then decode it into the above values. Lastly, you must check that the pubkey found by decoding the xpub is a value point on the secp256k1 curve.

Thank you for your quick and very informative reply!

Can this also be done in javascript (for input form validation), or are there special PHP functions that enable this?


text:
How to send a payment through a route saved in a json?
From lncli network=testnet sendtoroute -h:
NAME:
lncli sendtoroute - send a payment over a predefined route
USAGE:
lncli sendtoroute [command options] [arguments...]
DESCRIPTION:
Send a payment over Lightning using a specific route. One must specify
a list of routes to attempt and the payment hash. This command can even
be chained with the response to queryroutes. This command can be used
to implement channel rebalancing by crafting a self-route, or even
atomic swaps using a self-route that crosses multiple chains.
There are three ways to specify routes:
 * using the --routes parameter to manually specify a JSON encoded
   set of routes in the format of the return value of queryroutes:
       (lncli sendtoroute --payment_hash=<pay_hash> --routes=<route>)

 * passing the routes as a positional argument:
       (lncli sendtoroute --payment_hash=pay_hash <route>)

 * or reading in the routes from stdin, which can allow chaining the
   response from queryroutes, or even read in a file with a set of
   pre-computed routes:
       (lncli queryroutes --args.. | lncli sendtoroute --payment_hash= -

   notice the '-' at the end, which signals that lncli should read
   the route in from stdin
OPTIONS:
--payment_hash value, --pay_hash value  the hash to use within the payment's HTLC
--routes value, -r value                a json array string in the format of the response of queryroutes that denotes which routes to use

I use this command to save the routes in a json file:
lncli -network=testnet queryroutes 02e34c1b4c5f8e7419cf4d10e3bc9651d46dc1af68df6a7b81a24951a9192aa9c4 --final_cltv_delta=144 25000->routes.json

Then from the spec, performing:
lncli --network=testnet sendtoroute --payment_hash=03bd33db2dfdebff50ca8a7ae3bade681bbf7f25246248c9416b4441b1dbf4c2 --routes=routes.json

I always get back this error:
[lncli] unable to unmarshal json string from incoming array of routes: invalid character 'r' looking for beginning of value

Am I doing something wrong?  What should I set as --routes parameter?

I think the problem is that you are trying to pass the file name as an argument instead of the content of the file. Try passing the json through the standard input instead:
cat routes.json | lncli --network=testnet sendtoroute --payment_hash=...

using this i get:
[lncli] unable to unmarshal json string from incoming array of routes: invalid character 'â' looking for beginning of value

Interesting. Just in case, I assume you do not have a character like this in your routes.json?

Exactly. The content of routes.json is just the output of the queryroutes command.

Could you also try passing the routes as a std input? “cat routes.json | lncli sendtoroute ...”

Well passing the routes as std input works! It is a good workaround.

I am still puzzled why --routes="$(cat routes.json)" does not work for you. For me it succeeds, but maybe there are some bash differences.

Ok, Actually it works. I was missing the final "-".
Here the command:
lncli --network=testnet sendtoroute --payment_hash=03bd33db2dfdebff50ca8a7ae3bade681bbf7f25246248c9416b4441b1dbf4c2  --routes="$(cat routes.json)" -


text:
Is it possible to take advantage of FP16 for mining BTC or ALTs?
I know mining uses mostly Integers, not Floating Point Ops... but still, is it possible to use Graphics Cards that support native 16bit Math for mining? Will it improve the performance in specific Algorithms?
My point is, you have DOUBLE the GFLOPS in FP16 compared to FP32, so..... computationally wise it is debatable....

No l, floating point operation are pointless, regardless of how fast they are or what precision they have.
Also, BTC is mined using ASICs since 5 years ago or so, using a GPU is a waste of time and money.

I know about the ASICs, my question was about ALTs too, but further research from me and i noticed that in fact using Floats could change the HASH outputs when you use different precision, simply because 0.5 is a different number then 0.5001 for example!


text:
What is the algorithm that adjusts the difficulty of the proof of works in a proof of work based cryptocurrency?
For instance, Bitcoin has a proof of work based consensus algorithm, it's how Bitcoin chooses a node to create the next block in Bitcoin's blockchain. In this way the network is in consensus about the creation of the next block. Part of this block creation process is issuing the next proof of work to the network, and the consensus node, based off of the algorithm in question, may set a new difficulty on the proof of work. Bitcoin tries to keep this proof of work difficult enough but easy enough so that block creation times are around 10 minutes.
What is the algorithm that sets this difficulty?

The difficulty is a function of block creation speed.
The goal is to, on average, create blocks every 10 mins.
It is recalculated every two weeks (link)
You can look up the calculation of difficulty in the open source code of Bitcoin
https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49


text:
Is it possible to accurately map hashing power to network size?
Let's say we have a network with n nodes in it. Is it possible, when the hashing power of the network is calculated after a proof-of-work, to accurately estimate n with an algorithm taking the calculated hashing power into account?

There is no correlation between hash-power and number of validating full-nodes in the network.
Consider the following:
Hashrate is necessarily anonymous. Therefore, there is no way to determine how many miners are operating on the network. Furthermore, a miner may operate an arbitrary number of full-validation nodes, from which it creates its candidate blocks.
It is possible to approximate the global hash-rate from recent block intervals/difficulty, but this only captures hash rate that was working on the current strong-chain, not hash rate working on another branch (e.g. selfish mining). Even if we could approximate global hash-rate, it has no relation to the number of full-validating nodes.
Hash-rate is proportional to the demand for Bitcoin transactions. Higher confirmation demand will lead to higher fees in the fee market, resulting in new hash rate joining the market. One may assume that that higher confirmation demand may lead to higher full-validating node count, but that too is not guaranteed, if the node-validation is too costly (big blocks) and becomes centralised (custodial services).

I don't think so. This would only hold true if every node would be mining. But in the current situation of the bitcoin network most nodes are just verifying the blockchain and relying blocks and transactions. Only a few nodes are actually mining. They run a "mining server" which distributes mining problems to the mining hardware in their mining pools. So no you can't really map hashing power to network size.


text:
What incentive do miners have to respect the Replace-By-Fee flag?
Couldn't a miner treat all transactions in their mempool as if they had Replace-By-Fee enabled? After all they could always claim that they hadn't seen the original transaction.

Disrespecting it would require them modifying their software, which has ongoing administrative costs.
Otherwise, there any incentive within the system to behave otherwise. Willfully not taking income maximizing transactions isn't an incentive compatible behavior.

The second paragraph confuses me. The question asked whether miners could just treat everything as replaceable, and you point out that not taking the maximum income would be not incentive compatible. So did you mean the second sentence to be “However, there is incentive to behave otherwise."?


text:
Error when trying to view transaction details
Every time i try to click on any transaction history, it says, "Error. Transaction not available at this time."
Does anyone else have this issue?

Reason i'm asking is because i know copay is usually very quick with sending their bitcoin, however, the receiving end had yet to receive anything from copay.

And there is no way it got sent to the wrong address cause I scanned the QR code

Possible duplicate of Why is my transaction not getting confirmed and what can I do about it?

I believe this is a copay bug and should be asked here: https://github.com/bitpay/copay/issues


text:
Why should SPV nodes operate on the P2P network?
I understand there are advantages for the SPV client to acquire header-chain and subsequent inclusion proofs over the p2p network:

Peer discovery
P2P node interface is public
Reuse of P2P messaging protocol

But this must come at a cost for full-validating nodes:

Reduced channel bandwidth with full-nodes
Therefore, increased tx/block propagation times

Why are SPV nodes/clients not serviced over separate server-client interface rather than the P2P protocol? What are the justifications for this?
Thanks in advance.

How would using a different protocol between lightweight nodes and full nodes not equally reduce channel bandwidth for the latter?

P2P channels are generally long-lived. SPV nodes represent additional hop in data propagation without additional decentralisation (validation). I suppose a full-node could selectively drop SPV peers, but a server-client interface seems more efficient vs. P2P for those nodes which wish to act as public servers for SPV clients.


text:
Why are block header bits necessary? (Valid difficulty is already implied by chain history)
Difficulty or target is implied by chain history, so why does it need to be explicit in the header? I suppose it exposes miner-intended-difficulty, but I don't see why that would be relevant without chain context.
So it seemingly represents redundant data in the header, unless there are any historical reasons for this design choice?

So there are other SE questions/answers which imply that this was historical. But, what was the purpose of header bits to begin with? Was it an oversight?

Did you see https://bitcoin.stackexchange.com/questions/34155/is-it-necessary-for-blocks-to-record-the-nbits-difficulty-parameter?

Yes thank you. Still confuses me. SPV still needs to validate header chain from genesis, even if not all headers are stored, so that difficulty can be computed from header chain history. Bits not required.

Ok.  (In general, it's nice if you can include links to relevant questions that you've already seen, to avoid redundant suggestions :-).  I agree that I also can't see any reason why it's particularly necessary.  It's quite possible it was just for convenience / laziness on Satoshi's part, as it was easier than having the node store the data somewhere else, or else he simply didn't think it all the way through.  Sadly we can't ask him.

Thank you. I meant your link was new to me, not that I had already viewed it, it was useful! I wasn’t clear about that.

They aren't really necessary. The reason that they are included can only be known by Satoshi, and AFAIK, he did not state why he chose to include nBits in the block header (or many other things that are just arbitrary). This is one of the many things that Satoshi chose to do and no one really knows why. It remains in the block header today because removing it would require a hard fork and there really is not much benefit to be gained by removing it.
The nBits field can be useful, and it likely was included as a convenience sort of thing. Instead of having to have the full chain history in order to know the current difficulty, you can instead look at the nBits. But that is just speculation, and full nodes don't use the nBits to determine the current difficulty (except those of the genesis block).

Directly committing to the nbits allows you to determine how much work was used to produce the header statelessly before looking for (or fetching) information about prior headers.
This can help fend of DOS attacks sending junk headers to force you to do work determining or fetching their ancestors.

A heuristic for DoS prevention that made use of this existed in Bitcoin Core before the introduction of headers-first synchronization. Right now, I don't think it's used for anything in Core.

https://github.com/bitcoin/bitcoin/blob/ed12fd83ca7999a896350197533de5e9202bc2fe/src/validation.cpp#L3071

Sure, it lets us check whether the PoW matches the difficulty of headers without context. But an attacker could claim any value at that point, and we'd only detect it in the contextual validation. I don't think any meaningful attack is prevented by this.

CheckProofOfWork also checks nbits is at least the minimum. It could check 'apparent work' instead,  which would be almost as good, but you could for example flood with "lucky shares" from a hypoethical 1 block per second diff=0.1 altcoin. So it is different, even if not in an important way.

Ok, but it could do that without explicit nBits.

Thank you for your answers! Very helpful for my historical understanding of nbits.


text:
In ECDSA, why is (r,−s mod n) complementary to (r, s)?
I am trying to find resources in previous malleability posts, but couldn't find derivations/proofs of this fact or how the exact low-s value is derived. Any pointers would greatly appreciated.

ECDSA signatures are pairs (r,s) such that r = x(m/s*G + r/s*P) mod n, where P is the public key and m is the message digest. x() in that equation means "the X coordinate of".
In that equation, if you substitute s = -s', you get r = x(m/(-s')*G + r/(-s)*P) mod n, or r = x(-(m/s'*G + r/s'*P)).
However, it is true that for any point Q, x(Q) = x(-Q), as negating a point only affects the Y coordinate. Thus, r = x(m/s'*G + r/s'*P) mod n, or (r,s') is valid signature whenever (r,s) is.

Thank you very much. I understand negating a scalar over ff, but not why that negated scalar * point will result in a point with the same x-coord as scalar * point.

@JamesC. That follows from the group law definition, which says that (x,y) + (x,-y) = 0. This can be rearranged to (x,-y) = 0 - (x,y) = -(x,y). There isn't any particularly deep insight here, it's just how elliptic curve point addition is defined.


text:
Sweeping Private Key With Electrum
From Electrum's documentation, the following should sweep all private keys to a new address:
electrum listaddresses --funded | electrum getprivatekeys - | jq 'map(.[0])' | electrum sweep - [destination address]

Is there any way to enter a WIF key into the command line to specify it directly?  The address I'm wanting to sweep isn't in my Electrum.
For example, let's say this is the private key (never use this):  L3ei8Zdu3eVRxMifD8XFN14jofv25ME51AhTzJr999dazxrWZMrZ
And this is the address I want the coins swept to: 1KdcMcRXNTBYT5BnHcmFHuYvvdWGsPnnwb
Assume that neither the sending nor receiving address is in my Electrum wallet.
What would I need to enter in Electrum command-line?

The first two commands extract private keys from the electrum wallet. So you can simply pass on your private key (wif) and destination address to electrum sweep.
However, if your private key isn’t listed in electrum wallet, it may not know/hasn’t indexed which utxos this specific key can spend, which is necessary information for sweeping funds controlled by that private key. I am not sure if electrum indexes by all addresses(incl. those spendable by your private key), that will be critical to your ability to sweep.


text:
Initial Block Download Problem
I started a new Bitcoin Core(testnet) and the download of blocks worked perfectly till 15% and then i don't know what happened, but i got the following error:
unknown new rules activated (versionbit 1)
What should i do?

It seems that sync is finished, if you look at the picture i uploaded.

I cannot use any other Option

This is really busted.

This is not an error that has halted progress, the sync is continuing.
Warnings are informational messages that may need attention.


text:
Stay on memory pool when I sending multiple transaction from bitcoin wallet
I run the bitcoin client 0.17.1 on my ubuntu 18.04 desktop. I have some balance in my wallet. Also my client is fully synced.I have face the wallet conflict. When I send multiple transaction at once(without time gap). Happen two things.

Some transaction is confirmed and completed successfully
Some transaction is stay on the memory pool for a long time. And the status is show as 0/unconfirmed, in memory pool

If I send transaction with some of time gap, no problems is existing. Also I mention that I already used bumpfee RPC. But transaction stay on the unconfirmed stage.
Note: I give the proper fee for every transaction

Possible duplicate of Why is my transaction not getting confirmed and what can I do about it?

No, It is not my answer. This answer is say about the transaction fee. But in my case, I give the transaction fee than standard fee rate.

How many transactions are you sending at the same time? How long is the "time gap".

Almost 10 seconds !

How many transactions are you creating?

Almost 12 transactions

Bitcoin Core has locks in place that will stop multiple calls to build a transaction to be executed in parallel. Instead, they will be executed sequentially, as the lock gets relinquished by the previous call. So, the other thing that comes to mind is that there are limits to the ancestry set of transactions that may be submitted to the mempool at the same time.
Your own node's mempool will not accept more than 25 transactions or more than 101 kB in total transaction size that are chained/interdependent in some fashion. Your wallet will attempt to rebroadcast transactions to your own mempool every thirty minutes or so, so even when some of the ancestors of your transactions get confirmed, it may take a while for the others to be relayed to the network.
What you can do: If you're sending a very large number of transactions, e.g. more than 25 per block, you should split up your balance across a greater number of UTXOs, so that you can create a larger count of independent transactions.

Hi @Murch , Thanks for answering. I do not create 25 transactions. I only created approximately 12 transaction per block.

Are the transactions very large? Does your wallet have a very large number of unspents?

What is mean by transactions very large, Do you mean by very large amount...???

No, I'm talking about the data size of the transaction. Does it have a very large count of inputs?

No. It does not a large count of input

Also have any document is available to practically apply the greater number of UTXO for increase increase the count of transaction...??

Splitting your balance into more UTXO would only help if you have a large balance. Are you perhaps running out of confirmed funds and then start creating transactions that spend incoming funds sent from third parties? And those parent transactions take a long time to confirm?

Hey. I try bumpfee RPC. It show the error like "Error: The transaction was rejected: txn-mempool-conflict (code 18)".


text:
Submitt transaction with custome fee
I like to doing to submit every new transaction with user specific fee. I don't see any valid documentation for achieve it using RPC call. Give any suggestion.
Thankyou

Can you provide additional details as to what exactly you are trying to achieve?

Hi.. I try to setup a bitcoin web based wallet. I planning to setup a full node on cloud and do the wallet operation by using RPC call. I need to setup a user choosing fee for every withdrawal transaction. How to achieve it..??

Fees = inputs - outputs. You can just adjust how much the user is allowed to spend in the outputs when they are consuming their UTXO.

Any way are available to calculate the exact fee before sending transaction...???

Every transaction references input UTXOs (also called VOUTs) as VINs and outputs bitcoins to certain addresses. The input value, in bitcoins, is summed up. This sum is the maximum amount that can be allocated to outputs, but does not need to (and usually is not) what is completely allocated to outputs.
Usually, the sum of outputs is slightly less than the sum of inputs. In Bitcoin, the difference between these two is paid to the coinbase address of the block that the transaction is included in.
Most likely, your client uses the "change address" paradigm. From your HD wallet, a new key pair and address are derived. This new address serves as a change address. You specify how much bitcoins you want to spend to an output(s), the remaining amount is then calculated from the subtraction of all the specified output amounts. This remaining amount is then subtracted further, using a fee estimate. The final value is paid to that change address, which you control. The fee estimate then becomes what is paid to the miner. All of these operations are automated by your wallet client, so you normally don't need to fiddle with these change addresses. However, it can be customized.
Following this logic, all you need to do to customize your fee is to increase/decrease the number of bitcoins sent to your change address. The higher the number, the smaller the fee, and vice versa. After calculating all these parameters, you can then create a custom transaction, serialize it (createrawtransaction), sign it (signrawtransaction), and broadcast it.

Thanks for answering. Any documentation or any formula is available to calculate the fee...???


text:
Working of crypto currency swaping (Exchanging) in Crypto exchange
I am new in crypto. I know something about cryto currency and its working. I am curiosity about the working of Crypto exchange like binance,coinbase...etc... My doubts is

Some exchanges provide the swapping facilities like one click swapping from one cryto currency to another(That is without use of trading mechanism of buy order and sell order)...How it is possible ?
Actually the exchanges is hold a large amount of crypto asset for the users to provide one click swapping facilities to the users ....???

I expect a detailed explanation as possible from this community. Thanks

Any service or exchange allowing conversion of one asset into another (whether it is decentralized or centralized), is eventually executing the trade on an orderbook with a large exchange or liquidity provider.
Larger exchanges like Coinbase, Binance, Bitstamp etc. operate their own orderbooks, which have liquidity from users and market makers.
Second tier services like Shapeshift, Changelly etc. maintain balances in all the coins they support on larger services, and when a user wishes to convert an asset, they will execute a corresponding trade on these services.

That is they are actually use the trading mechanism for provide swapping facilities. Is it right...???

Yes, that's right.

Can you clear one more doubts please.  How it implement?? using trading api that are provided by coinbase like platform...???

The implementation details will vary depending on the services used - most exchanges offer REST or websocket APIs, while market makers might offer FIX APIs. It's impossible to provide a good answer without more details

This answer is not entirely correct.  Bisq (decentralized exchange) only allows peer-to-peer trades -- there is no interaction with another "larger" centralized exchange.  Also, one can use Atomic swaps to exchange cryptocurrencies with no middleman / liquidity provider / escrow.


text:
Notify when new transaction is arrive in a bitcoin address
I have bitcoin full node on the server. I need to notify when new incoming transaction is arrive into a bitcoin address. Is there any RPC will help to achieve my goal ...
Any help is appreciable. Thank you

Try using ZeroMQ to listen to transaction event.
You can subscribe to hashtx or rawtx events.
Here is a nodejs example taken from this great guide by GR0KCHAIN: https://bitcoindev.network/accessing-bitcoins-zeromq-interface/
var zmq = require('zmq')
  , sock = zmq.socket('sub')
  , RpcClient = require('bitcoind-rpc');

var config = {
    protocol: 'http',
    user: 'bitcoin',
    pass: 'local321',
    host: '127.0.0.1',
    port: '18443',
};

var rpc = new RpcClient(config);

console.log("T")
sock.connect('tcp://127.0.0.1:29000');

sock.subscribe('rawtx')

sock.on('message', function(topic, message) {
  rpc.decodeRawTransaction(message.toString('hex'), function(err, resp) {
        console.log(JSON.stringify(resp, null, 4))
  })
})

Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.

Added a short example.

Notify when new transaction is arrive in a bitcoin address

To achive this what i have implemented is:
You need to have a crawler running on cronjob, which crawls each blocks(as well as mempool if you want to send 0th confirmation notification) and each transactions. While crawling transactions you need to check if its vout address i.e to_address of particular transaction is your address or not. If its your address you need to implement a notification service notifying
to_address, value , txid and other required parameters.
You can use redis for faster comparision of transactions and addresses
rpc required :
getblockcount,getblockhash, getblock, getrawtransaction, getrawmempool

If the address doesn't have to be specific then you have a few options:

Use ZeroMQ for catching every single transaction that enters the mempool and check if it's relevant to your addresses.
Use walletnotify as a startup flag/config option to specify a command to execute with an option to pass the txid to the command. This will only catch the relevant transactions (so whenever one of your addresses is used as an input or output). However, it creates a new process every time that command gets executed, which, as far as I know, has a negative effect on the resources of your machine.
Read the txids from the stdout. This is the method I've been using. Things like new blocks and new transaction registration get logged in the stdout of the bitcoin core process. If you find a way to pipe that stdout somewhere and then extract txids or new block hashes there - you would, in essence, have the same relevant only notifications, but without spawning new processes.

Thanks a lot. Do you know any step-by-step guide to setup ZeroMQ for catching every single transaction enters the mempool?

@AminShojaei what language are you using?

currently Php 7

I am using PHP7

No, sorry, I am not familiar with implementation of ZeroMQ in PHP

What about NodeJS or Python?
I am ok with the ZMQ. the problem is <How to connect ZMQ and Bitcoind?>

Here's a NodeJS guide that worked for me: https://degreesofzero.com/article/streaming-transactions-from-bitcoind-via-zeromq.html

Bitcoin Core's RPC mechanism is not a push interface and does not support notifications. Each RPC returns one JSON object, so to implement notification functionality using this, your application will frequently need to poll the bitcoin daemon for new information.
The RPC you probably want is listtransactions. This will return a list of recent transactions with their full details, which includes the pay-to address and the time it was added. Your application would simply filter out the transactions whose timestamp is earlier than the most recent notification, and create a notification for those whose timestamps are newer.


text:
Setup a full node on server for frond end Wallet
I am a new in bitcoin technologies. I want to setup a full node on cloud server. Also I need to use RPC of this server for front end app.That is creating bitcoin wallet and its further operations(such as send and receive). My question is

Is suitable to use own full node cloud server for front end wallet app(Like PHP web app) ...?

Thanks in advance.

Yes, but a few important points.

Don't forget to enable txindex, it will allow you to query your node for all transactions.
Don't use the RPC API on the front end. RPC is needed to make transactions, but it might allow others to withdraw your coins. Keep the RPC in the back end.
The HTTP REST API is suitable for front end use.
Don't keep your funds on a client on a cloud server unless you trust them.
The front end shouldn't contact the node to make transactions or handle the private keys, instead, you should use BitcoinJS or Bitcore-lib to create transactions on the front end.

Hey...Thanks for answering. I expect more helps from you. May I ask an another question please. How to create multiple wallet for multiple users on frond end (I already know to creating multiple account address)....?

Actually multiple address = = Multiple wallet....???

Hey... Please respond..

On the front end? You can hash the username and password to derive the seed, so don't store them (either in the front end or in the back end). Then you can generate addresses/private keys by applying BIP32 transformations, which should be the wallet and should be unique to each user. @salmanfaris

Thanks for responding @MCCCS .I understand something. But not everything. Actually what is BIP32 transaction. And how generate unique address for each users. I thing that generate address for each users by using RPC call getnewaddress .Is it correct..?

BIP32, also called a HD wallet, is a way to create multiple addresses for a wallet while being able to generate keys by only storing the master key. You can use getnewaddress to generate a receiving address for Bitcoin Core, but as you'll keep the private keys and funds in Core, make sure to keep the node as secure as you can.

Actually I don't understand the statement "is a way to create multiple addresses for a wallet while being able to generate keys by only storing the master key". How can possible to implement it. Any practical documents are available to achieve that..??

@salmanfaris Here's an explanation : https://medium.com/bitcraft/hd-wallets-explained-from-high-level-to-nuts-and-bolts-9a41545f5b0 You can search for "PHP HD wallet" or "PHP BIP32" to find an implementation.


text:
Wrong format Transaction ID
I have a BTC block chain which is stuck (3 weeks). I am using blockchaininfo .When I enter two of the transaction IDs ( cut and pasted ) it reports wrong format . A third transaction hashtag is accepted and reported to be confirmed. What is happening?

What are the three transaction IDs?

Hello Ian, welcome to Bitcoin SE. It's difficult for me to tell what you're asking. You say that you have a stuck transaction and seem to be asking about an unrelated issue with broken transaction ids. Could you please elaborate the significance of the various pieces of data, or perhaps even provide them so that we can take a look around ourselves? I've put the question on hold, but please do edit additional information into it and flag for reopening.


text:
difference between inbound and outbound connection
I'm running a bitcoin full node (bitcoin core) via Tor.
I noticed I have only outbound connections (using maxconnections=16 in the conf file), but not even an inbound one.
So which is exactly  the difference between inbound and outbound?
I'm able to regularly receive update tips and relay my transactions to the network however.
Furthermore, I set the onlynet=onion option, so I should exclusively receive from and relay to onion addresses

When your client start the connection with another peer it is outbound, otherwise it is inbound.
If you want to be sure that your tor node is properly setup and that other peer can connect to you, check: https://en.bitcoin.it/wiki/Setting_up_a_Tor_hidden_service

This is backwards.

whoops, fixed it ;)


text:
Types of onion address
I'm running a bitcoin core full node with Tor and I've configured a hidden service for that.
The point is: bitcoin core log shows me an onion address which is very smaller than the one I found in /var/lib/tor/bitcoin-service/hostname.
I noticed that other peers in the network connect with me using the small .onion address.
Which is the difference between these two types of onion address? Are they correlated eachother in some way?
I've also tried to use the longer . onion address in the externalip option inside bitcoin.conf, but it gave me an error.

The small address is the address onion v2 and the long address is the address onion v3, but I know a lot of tor, try to use the StackExchange tor https://tor.stackexchange.com/

I read somewhere that bitcoin core doesn't support onion V3. However, I'll repost this question in the tor forum


text:
-fallbackfee option in sendtoaddress
I'm trying to send some bitcoins using bitcoin-cli API, but bitcoin core tells me that Fallbackfee is disabled. How can I set a value for fallbackfee?
I've tried to specify it like
 bitcoin-cli sendtoaddress -fallbackfee=someValue but it didn't work.
 I've also set true for substractfeefromamount and false for replaceable

It seem like you tried to run fallbackfee in the terminal ? fallbackfee is a configuration option and should be put inside a bitcoin.conf file, if you dont have this file on your bitcoin directory you can create it: https://en.bitcoin.it/wiki/Running_Bitcoin#Bitcoin.conf_Configuration_File
Then add your fallbackfee=someValue (without the -) inside your bitcoin.conf file on a new line then restart your bitcoin client and try your command again.

Another option that works for me is to call the settxfee with amount before calling sendtoaddress.


text:
c-lightning missing outputs
A few days ago I did a submarine swap in order to rebalance a channel of mine. I opted to be refunded on-chain using a brand-new address generated with c-lightning newaddr command. I used the p2sh address (aka starting with 3...) because last time I had some issues with the bech32 version.
Here is the point: the on-chain transaction has (at time of writing) more than 80 confirmations, but my c-lightning node still cannot show the output with the listfunds command.
Using dev-rescan-outputs didn't get any results as well.
Am I miss something? Have that utxo gone lost?

your not bitcoin is update to the network?

absolutely yes, up and running

So lightning-cli getinfo has the same blockheight as bitcoin-cli getblockchaininfo and it matches what blockexplorers say is the latest block? You can try rescanning using --rescan=-confirmationheight (notice the minus in front of the absolute height).

both have 608865 as block-height

rescan completed, no results at all. Really concerned of losing those funds

No worries, if the funds are there, we should be able to recover them. Might just be a regression that we fail to look for p2sh outputs.

For more flexibility in debugging this issue we migrated the discussion here https://github.com/ElementsProject/lightning/issues/3359

We will write a summary here once the issue has been resolved with the necessary details.

For readers, this issue has been solved by @cdecker here: https://github.com/ElementsProject/lightning/issues/3359.
TL;DR: Use the --rescan startup parameter of lightningd.