Re: Transaction Fee - getInputSum() / getFee()
So this is a limitation of Bitcoinj, I can solve this by abandoning this dependency and using instead the bitcoin core project itself, correct? On Monday, 10 July 2017 17:30:17 UTC-3, Andreas Schildbach wrote: > > It's a limitation of the Bitcoin protocol, inputs do not have value it's > their connected output. In bitcoinj, only the Wallet class connects the > inputs to their outputs; since you probably don't use the Wallet you > likely need to do the connecting yourself. > > > On 07/06/2017 05:54 PM, Wladimir Filho wrote: > > Hi, I'm developing a block explorer in java using BITCOINJ version > 0.14.4. > > > > There is a problem that can not be answered on the internet or in the > > forum, I can not access information in the Transaction Input as the fee > > or sum of the inputs. I tried to use the *SPVBlockStore* to > > *MySQLFullPrunedBlockStore* for a complete copy of the blockchain, even > > though the information remains "hidden". > > > > I need this information to develop services like: > > > > https://blockchain.info | https://live.blockcypher.com | > > https://blockexplorer.com/ > > > > Below is part of the application code: > > > > > > | > > > > > > > > > publicstaticMySQLFullPrunedBlockStorecreateStore(NetworkParametersparams,intblockCount) > > > > > >throwsBlockStoreException{ > > > > > > > > returnnewMySQLFullPrunedBlockStore(params,blockCount,DB_HOSTNAME,DB_NAME,DB_USERNAME,DB_PASSWORD); > > > > > > } > > > > > > privatestaticNetworkParametersnetworkParameters > =TestNet3Params.get(); > > > > > > publicstaticvoidmain(String[]args)throwsException { > > > > > > MySQLFullPrunedBlockStorechainStore > > =createStore(networkParameters,1000); > > > > FullPrunedBlockChainchain > > =newFullPrunedBlockChain(networkParameters,chainStore); > > > > > > PeerGrouppeerGroup =newPeerGroup(networkParameters,chain); > > > >peerGroup.addPeerDiscovery(newDnsDiscovery(networkParameters)); > > > > > > > > BlockDownloadedManagerblockDM =newBlockDownloadedManager(); > > > > > > peerGroup.startAsync(); > > > > peerGroup.addBlocksDownloadedEventListener(blockDM); > > > > peerGroup.downloadBlockChain(); > > > > blockDEL.wait(); > > > > > > > > peerGroup.stop(); > > > > } > > > > > > > > > publicclassBlockDownloadedManagerimplementsBlocksDownloadedEventListener{ > > > > > > > >@Override > > > > > > > > publicvoidonBlocksDownloaded(Peerpeer,Blockblock,FilteredBlockfilteredBlock,intblocksLeft){ > > > > > > > > > System.out.println("-"); > > > > > > System.out.println("hash - "+block.getHashAsString()); > > > > System.out.println("transactions numer - > > "+block.getTransactions().size()); > > > > > > > >blockDetail(block); > > > >} > > > > > >staticvoidblockDetail(Blockblock){ > > > > Listtx_list =block.getTransactions(); > > > > > > for(Transactiont :tx_list){ > > > > System.out.println("hash - "+t.getHashAsString()); > > > > System.out.println("input sum -"+t.getInputSum()); > > > >System.out.println("output sum -"+t.getOutputSum()); > > > >System.out.println("fee calc - > > > "+(t.getInputSum().getValue()>0?t.getInputSum().getValue()-t.getOutputSum().getValue():0)); > > > > > > System.out.println("fee -"+t.getFee()); > > > > System.out.println("size - "+t.getMessageSize()); > > > > } > > > >} > > > > } > > > > > > | > > > > > > > > > > *LOGS:* > > > > > > > - > > > > > > hash - e95fbedad07b7f95fa56e95ba11ed40f6a9f4b74fa2e0ce128ff6a42 > > > > transactions numer - 1 > > > > hash - d2e1049b895946525eb480070bcf678d94f709d6d621d79415dacb5ce73ac9db > > > > input sum -0 > > > > output sum -50 > > > > fee calc - 0 > > > > fee -null > > > > size - 96 > > > > > - > > > > > > hash - 409087525f6977c2634e636509e20bc61bc1c6e86eb6d17a394d7a7a > > > > transactions numer - 2 > > > > hash - 1b93146ca6ec328b8f9e976fd49cd8dd4b74f2c1277807c75e941991948701bb > > > > input sum -0 > > > > output sum -50 > > > > fee calc - 0 > > > > fee -null > > > > size - 96 > > > > hash - e2e5b1e29596105817b74f50cfde585baeeddb6125f9e03e8a22858def9293f2 > > > > input sum -0 > > > > output sum -49 > > > > fee calc - 0 > > > > fee -null > > > > size - 192 > > > > > - > > > > > > hash -
Re: Transaction Fee - getInputSum() / getFee()
It's a limitation of the Bitcoin protocol, inputs do not have value it's their connected output. In bitcoinj, only the Wallet class connects the inputs to their outputs; since you probably don't use the Wallet you likely need to do the connecting yourself. On 07/06/2017 05:54 PM, Wladimir Filho wrote: > Hi, I'm developing a block explorer in java using BITCOINJ version 0.14.4. > > There is a problem that can not be answered on the internet or in the > forum, I can not access information in the Transaction Input as the fee > or sum of the inputs. I tried to use the *SPVBlockStore* to > *MySQLFullPrunedBlockStore* for a complete copy of the blockchain, even > though the information remains "hidden". > > I need this information to develop services like: > > https://blockchain.info | https://live.blockcypher.com | > https://blockexplorer.com/ > > Below is part of the application code: > > > | > > > > publicstaticMySQLFullPrunedBlockStorecreateStore(NetworkParametersparams,intblockCount) > >throwsBlockStoreException{ > > > > returnnewMySQLFullPrunedBlockStore(params,blockCount,DB_HOSTNAME,DB_NAME,DB_USERNAME,DB_PASSWORD); > > } > > > privatestaticNetworkParametersnetworkParameters =TestNet3Params.get(); > > > publicstaticvoidmain(String[]args)throwsException { > > > MySQLFullPrunedBlockStorechainStore > =createStore(networkParameters,1000); > > FullPrunedBlockChainchain > =newFullPrunedBlockChain(networkParameters,chainStore); > > > PeerGrouppeerGroup =newPeerGroup(networkParameters,chain); > >peerGroup.addPeerDiscovery(newDnsDiscovery(networkParameters)); > > > > BlockDownloadedManagerblockDM =newBlockDownloadedManager(); > > > peerGroup.startAsync(); > > peerGroup.addBlocksDownloadedEventListener(blockDM); > > peerGroup.downloadBlockChain(); > > blockDEL.wait(); > > > > peerGroup.stop(); > > } > > > > publicclassBlockDownloadedManagerimplementsBlocksDownloadedEventListener{ > > > >@Override > > > > publicvoidonBlocksDownloaded(Peerpeer,Blockblock,FilteredBlockfilteredBlock,intblocksLeft){ > > > System.out.println("-"); > > System.out.println("hash - "+block.getHashAsString()); > > System.out.println("transactions numer - > "+block.getTransactions().size()); > > > >blockDetail(block); > >} > > >staticvoidblockDetail(Blockblock){ > > Listtx_list =block.getTransactions(); > > > for(Transactiont :tx_list){ > > System.out.println("hash - "+t.getHashAsString()); > > System.out.println("input sum -"+t.getInputSum()); > >System.out.println("output sum -"+t.getOutputSum()); > >System.out.println("fee calc - > "+(t.getInputSum().getValue()>0?t.getInputSum().getValue()-t.getOutputSum().getValue():0)); > > System.out.println("fee -"+t.getFee()); > > System.out.println("size - "+t.getMessageSize()); > > } > >} > > } > > > | > > > > > *LOGS:* > > > - > > hash - e95fbedad07b7f95fa56e95ba11ed40f6a9f4b74fa2e0ce128ff6a42 > > transactions numer - 1 > > hash - d2e1049b895946525eb480070bcf678d94f709d6d621d79415dacb5ce73ac9db > > input sum -0 > > output sum -50 > > fee calc - 0 > > fee -null > > size - 96 > > - > > hash - 409087525f6977c2634e636509e20bc61bc1c6e86eb6d17a394d7a7a > > transactions numer - 2 > > hash - 1b93146ca6ec328b8f9e976fd49cd8dd4b74f2c1277807c75e941991948701bb > > input sum -0 > > output sum -50 > > fee calc - 0 > > fee -null > > size - 96 > > hash - e2e5b1e29596105817b74f50cfde585baeeddb6125f9e03e8a22858def9293f2 > > input sum -0 > > output sum -49 > > fee calc - 0 > > fee -null > > size - 192 > > - > > hash - d986f90a094b707e9ef4bf412d9a2a14df872e9409ddca7e0865bde6 > > transactions numer - 2 > > hash - 5ccf7e3494f5f05398b04f6bb3a72b635b2de6c494572c3e2078c8d89532abb3 > > input sum -0 > > output sum -55 > > fee calc - 0 > > fee -null > > size - 96 > > hash - 23cc5dadd87f91c1fdce9c0ad090ce8f6e7fd7f79834ad1e579cd5a952c7c6b1 > > input sum -0 > > output sum -4904431364 > > fee calc - 0 > > fee -null > > size - 373 > > - > > hash - 4480dd8aa5a351cb8d66fb332496f4d54c97fb87584322ab05342144 > > transactions numer - 1 > > hash - 848771ee8e27418ec8af0c08ecfa61d6af230dfd6ab25809f5792565b4f57b85 > > input sum -0 > > output sum -50 > > fee calc - 0 > > fee -null > >