Commit graph

17832 commits

Author SHA1 Message Date
practicalswift
d06330396f wallet: Avoid potential null pointer dereference in CWalletTx::GetAvailableCredit(...) 2018-07-17 10:58:22 +02:00
practicalswift
fa39f674ae bench: Remove unused variable 2018-07-17 10:11:57 +02:00
Andrew Chow
020628e3a4 Tests for PSBT
Added functional tests for PSBT that test the RPCs. Also added all
of the BIP 174 test vectors (except for the updater tests) in the
functional tests.

Added a Unit test for the BIP 174 updater test vector.
2018-07-16 17:05:30 -07:00
Andrew Chow
a4b06fb42e Create wallet RPCs for PSBT
walletprocesspsbt takes a PSBT format transaction, updates the
PSBT with any inputs related to this wallet, signs, and finalizes
the transaction. There is also an option to not sign and just
update.

walletcreatefundedpsbt creates a PSBT from user provided data
in the same form as createrawtransaction. It also funds the transaction
and takes an options argument in the same form as fundrawtransaction.
The resulting PSBT is blank with no input or output data filled
in.
2018-07-16 16:08:24 -07:00
Andrew Chow
c27fe419ef Create utility RPCs for PSBT
decodepsbt takes a PSBT and decodes it to JSON

combinepsbt takes multiple PSBTs for the same tx and combines them.

finalizepsbt takes a PSBT and finalizes the inputs. If all inputs
are final, it extracts the network serialized transaction and returns
that instead of a PSBT unless instructed otherwise.

createpsbt is like createrawtransaction but for PSBTs instead of
raw transactions.

convertpsbt takes a network serialized transaction and converts it
into a psbt. The resulting psbt will lose all signature data and
an explicit flag must be set to allow transactions with signature
data to be converted.
2018-07-16 16:08:24 -07:00
James O'Beirne
db6eb90094 [doc] Remove outdated comment about mining code ignoring CPFP
BlockAssembler chooses transactions on the basis of packages (which incorporate
unconfirmed ancestors into feerate), so the specified RBF comment about mining
code ignoring CPFP is out of date.
2018-07-16 18:34:28 -04:00
MarcoFalke
0568dcd67d
Merge #13679: Initialize m_next_send_inv_to_incoming
347b4ff825 Initialize m_next_send_inv_to_incoming (Pieter Wuille)

Pull request description:

  This fixes an uninitialized variable introduced in #13298.

Tree-SHA512: 0c6fb164164141036fbbc955475650724bffdb3593c22946f55ac715fa162183bf9377a8390ee9d13f104be22bc417445e2c7fb3d4acf5e6236ac802e50f3e77
2018-07-16 17:30:43 -04:00
Pieter Wuille
347b4ff825 Initialize m_next_send_inv_to_incoming 2018-07-16 14:08:38 -07:00
Pieter Wuille
f8d470e246
Merge #13298: Net: Bucketing INV delays (1 bucket) for incoming connections to hide tx time
d45b344ffd Bucket for inbound when scheduling invs to hide tx time (Gleb)

Pull request description:

  It has been brought up to my attention that current random delays mechanism (originally intended to obfuscate transaction metadata) allows to easily estimate the time a transaction was received by a node.

  It may be done by connecting multiple observer nodes to the same node. Each of those nodes will generate its own schedule of delays. Combined metadata regarding those events from different sources allows an observer to estimate transaction time.

  After this patch a spy won't gain additional information by just creating multiple connections to a target.

Tree-SHA512: c71dae5ff350b614cb40a8e201fd0562d3e03e3e72a5099718cd451f0d84c66d5e52bbaf0d5b4b75137514c8efdedcc6ef4df90142b360153f04ad0721545ab1
2018-07-16 10:37:02 -07:00
Chun Kuan Lee
78f06e4af7 Migrate gitian-build.sh to python 2018-07-16 13:01:09 +00:00
Wladimir J. van der Laan
17943f77bd
Merge #13652: rpc: Fix that CWallet::AbandonTransaction would leave the grandchildren, etc. active
89e70f9d7f Fix that CWallet::AbandonTransaction would only traverse one level (Ben Woosley)

Pull request description:

  Prior to this change, it would mark only the first layer of
  child transactions abandoned, due to always following the input `hashTx`
  rather than the current `now` tx.

Tree-SHA512: df068b49637d299ad73237c7244005fe5aa966d6beae57aff12e6948f173d9381e1b5d08533f7e3a1416991ed57f9f1f7b834057141d85c07dc60bb1f0872cea
2018-07-16 14:53:30 +02:00
MarcoFalke
171b03de06
Merge #13664: Trivial: fix references to share/rpcuser (now share/rpcauth)
c64cc1bd94 scripted-diff: Fix references to share/rpcuser (now share/rpcauth) (Mason Simon)

Pull request description:

  Commit 3fdb297 renamed share/rpcuser to share/rpcauth but left references to the old path in code; this commit fixes the old references.

  ```
  -BEGIN VERIFY SCRIPT-
  git grep --files-with-matches 'share/rpcuser' src/*.cpp | xargs sed -i -E 's:share/rpcuser:share/rpcauth:g'
  git grep --files-with-matches 'share/rpcuser' test/functional/*.py | xargs sed -i -E 's:share/rpcuser:share/rpcauth:g'
  -END VERIFY SCRIPT-
  ```

Tree-SHA512: 0ae5c746cfbaf38683e636382a9d518bbce123d308b1c8d47c1b089cc2e64dd6a7098cdfb6606ed5a9abc867d948a14022c3f3065f64076086ded429a7fa3cc7
2018-07-16 07:06:19 -04:00
Wladimir J. van der Laan
19d8ca5cc1
Merge #13171: Change gitian-descriptors to use bionic instead
c1afe3232f Change gitian-descriptors to use bionic instead (Chun Kuan Lee)

Pull request description:

  I have tested this with Ubuntu Bionic host with lxc 3.0.0, the gitian-build for Windows and MacOSX work fine, but there is an issue about it for Linux. Failed at check-symbol:
  ```
  test/test_bitcoin: symbol __divmoddi4 from unsupported version GCC_7.0.0
  test/test_bitcoin: symbol log2f from unsupported version GLIBC_2.27
  qt/bitcoin-qt: symbol __divmoddi4 from unsupported version GCC_7.0.0
  qt/bitcoin-qt: symbol log2f from unsupported version GLIBC_2.27
  ```
  I think this should be fixed in `./configure --enable-glibc-back-compat`

  Should not be merged before #13177 devrandom/gitian-builder#178

  Close #12511

Tree-SHA512: 257d75d5b6864e105279f7a7b992fbbd7903cdbe3300b66dacec0a783d267707d9dbbfe0e64a36983ca1eca50a2a5e1cdb222b6d3745ccc3e5fc5636c88b581f
2018-07-16 12:50:24 +02:00
Chun Kuan Lee
c1afe3232f Change gitian-descriptors to use bionic instead 2018-07-16 10:42:32 +00:00
Aaron Clauson
822a2a33a7 Modified in_addr6 cast in CConman class to work with msvc. 2018-07-16 16:29:27 +10:00
Mason Simon
c64cc1bd94 scripted-diff: Fix references to share/rpcuser (now share/rpcauth)
Commit 3fdb29778a renamed share/rpcuser to share/rpcauth but left references to the old path in code; this commit fixes the old references.

Performed update using https://github.com/facebook/codemod with command: `codemod --extensions cpp,py,md 'share/rpcuser' 'share/rpcauth'`

-BEGIN VERIFY SCRIPT-
git grep --files-with-matches 'share/rpcuser' src/*.cpp | xargs sed -i -E 's:share/rpcuser:share/rpcauth:g'
git grep --files-with-matches 'share/rpcuser' test/functional/*.py | xargs sed -i -E 's:share/rpcuser:share/rpcauth:g'
-END VERIFY SCRIPT-
2018-07-15 17:56:02 -07:00
MarcoFalke
c0f1569557
Merge #13368: Update gitian-build.sh for docker
86967b2e35 Add option to use docker for gitian-build.sh (Andrew Chow)

Pull request description:

  Updates gitian-build.sh script for the docker virtualization method recently added to gitian-builder.

  Second commit depends on https://github.com/devrandom/gitian-builder/pull/185

Tree-SHA512: 0fa50b6c1be35a7a39f4a82816369637d3d0082922ac9876b80ae8156c795dec0ff34ad384b5348777042df8ddb6a72bbaeddd7002ef80557b10e2acf46632aa
2018-07-15 17:26:18 -04:00
Jonas Schnelli
be98b2d9a8
[QA] Add scantxoutset test 2018-07-15 21:18:11 +01:00
Jonas Schnelli
eec7cf7b33
scantxoutset: mention that scanning by address will miss P2PK txouts 2018-07-15 21:18:11 +01:00
Jonas Schnelli
94d73d32ab
scantxoutset: support legacy P2PK script type 2018-07-15 21:18:10 +01:00
Jonas Schnelli
892de1dfea
scantxoutset: add support for scripts 2018-07-15 21:18:06 +01:00
Jonas Schnelli
78304941f7
Blockchain/RPC: Add scantxoutset method to scan UTXO set 2018-07-15 21:17:23 +01:00
MarcoFalke
8803c9132a
Merge #13138: [tests] Remove accounts from wallet_importprunedfunds.py
38040c34e1 [tests] Remove accounts from wallet_importprunedfunds.py (John Newbery)

Pull request description:

  This was split from #13075 to not block review/merge of that PR.

Tree-SHA512: 631d7139ed2bda5222ec395cc75720261e2e1f741dba04723d09fe04ef6cf92222a3679d886026ec33e2db2d1e2fa1a0f36c2451581d0f733a9939a98c7118ab
2018-07-14 13:08:31 -04:00
Ben Woosley
3fe836b78d
[moveonly] Extract RescanWallet to handle a simple rescan
Where the outcome does not depend on the result, apart from a simple
success check.
2018-07-14 12:42:28 -04:00
MarcoFalke
fa43a4138b
bench_bitcoin: Avoid read/write to default datadir 2018-07-14 10:46:54 -04:00
MarcoFalke
ea80b81e2e test_bitcoin: Avoid read/write to default datadir 2018-07-14 10:36:14 -04:00
Gleb
d45b344ffd Bucket for inbound when scheduling invs to hide tx time 2018-07-13 23:14:35 -07:00
Pieter Wuille
b25a4c2284
Merge #13072: Update createmultisig RPC to support segwit
f40b3b82df [tests] functional test for createmultisig RPC (Anthony Towns)
b9024fdda3 segwit support for createmultisig RPC (Anthony Towns)
d58055d25f Move AddAndGetDestinationForScript from wallet to outputype module (Anthony Towns)
9a44db2e46 Add outputtype module (Anthony Towns)

Pull request description:

  Adds an "address_type" parameter that accepts "legacy", "p2sh-segwit", and "bech32" to choose the type of address created. Defaults to "legacy" rather than the value of the `-address-type` option for backwards compatibility.

  As part of implementing this, OutputType is moved from wallet into its own module, and `AddAndGetDestinationForScript` is changed to apply to a `CKeyStore` rather than a wallet, and to invoke `keystore.AddCScript(script)` itself rather than expecting the caller to have done that.

  Fixes #12502

Tree-SHA512: a08c1cfa89976e4fd7d29caa90919ebd34a446354d17abb862e99f2ee60ed9bc19d8a21a18547c51dc3812cb9fbed86af0bef2f1e971f62bf95cade4a7d86237
2018-07-13 20:31:13 -07:00
Pieter Wuille
1329ef1f00
Merge #13651: [moveonly] Extract CWallet::MarkInputsDirty, and privatize AddToWalletIfInvolvingMe
17e6aa8e33 Privatize CWallet::AddToWalletIfInvolvingMe (Ben Woosley)
b7f5650942 Extract CWallet::MarkInputsDirty (Ben Woosley)

Pull request description:

  Thus reducing code and surface area of CWallet.

Tree-SHA512: 31a99acc77ef3438ef9b95d60030972b707bd69d6e7b1498a5f776b219d9aabc83464f75bfec7bad5cb635d0b2d686c389914e5cc57a4bb0b93c47bd82ca608c
2018-07-13 20:24:37 -07:00
Pieter Wuille
9a1ad2c5cb
Merge #11658: During IBD, when doing pruning, prune 10% extra to avoid pruning again soon after
ac51a26bdc During IBD, when doing pruning, prune 10% extra to avoid pruning again soon after (Luke Dashjr)

Pull request description:

  Pruning forces a chainstate flush, which can defeat the dbcache and harm performance significantly.

  Alternative to #11359

Tree-SHA512: 631e4e8f94f5699e98a2eff07204aa2b3b2325b2d92e8236b8c8d6a6730737a346e0ad86024e705f5a665b25e873ab0970ce7396740328a437c060f99e9ba4d9
2018-07-13 20:16:41 -07:00
Pieter Wuille
1e90862f5d
Merge #13417: [net] Tighten scope in net_processing
3339ba28e9 Make g_enable_bip61 a member variable of PeerLogicValidation (Jesse Cohen)
6690a28606 Restrict as much as possible in net_processing to translation unit (Jesse Cohen)
1d4df02b7e [move-only] Move things only referenced in net_processing out of header file (Jesse Cohen)
02bbc05310 Rescope g_enable_bip61 to net_processing (Jesse Cohen)

Pull request description:

  As part of a larger effort to decouple net_processing and validation a bit, these are a bunch of simple scope cleanups. I've moved things out of the header file that are only referenced in net_processing and added static (or anonymous namespace) modifiers to everything possible in net_processing.

  There are a handful of functions which could be static except that they are exposed for the sake of unit testing - these are explicitly commented. There has been some discussion of a compile time annotation, but no conclusion has been reached on that yet.

  This is somewhat related to other prs #12934 #13413 #13407 and will be followed by prs that reduce reliance on cs_main to synchronize data structures which are translation unit local to net_processing

Tree-SHA512: 46c9660ee4e06653feb42ba92189565b0aea17aac2375c20747c0d091054c63829cbf66d2daddf65682b58ce1d6922e23aefea051a7f2c8abbb6db253a609082
2018-07-13 20:10:55 -07:00
Pieter Wuille
ad552a54c5
Merge #13566: Fix get balance
702ae1e21a [RPC] [wallet] allow getbalance to use min_conf and watch_only without accounts. (John Newbery)
cf15761f6d [wallet] GetBalance can take a min_depth argument. (John Newbery)
0f3d6e9ab7 [wallet] factor out GetAvailableWatchOnlyBalance() (John Newbery)
7110c830f8 [wallet] deduplicate GetAvailableCredit logic (John Newbery)
ef7bc8893c [wallet] Factor out GetWatchOnlyBalance() (John Newbery)
4279da4785 [wallet] GetBalance can take an isminefilter filter. (John Newbery)

Pull request description:

  #12953 inadvertently removed the functionality to call `getbalance "*" <int> <bool>` to get the wallet's balance with either minconfs or include_watchonly.

  This restores that functionality (when `-deprecatedrpc=accounts`), and also makes it possible to call ``getbalance minconf=<int> include_watchonly=<bool>` when accounts are not being used.

Tree-SHA512: 67e84de9291ed6d34b23c626f4dc5988ba0ae6c99708d02b87dd3aaad3f4b6baa6202a66cc2dadd30dd993a39de8036ee920fcaa8cbb1c5dfe606e6fac183344
2018-07-13 19:46:31 -07:00
Pieter Wuille
90b1c7e5c5
Merge #13659: build: add missing leveldb defines
768981c93d build: add missing leveldb defines (Cory Fields)

Pull request description:

  Fixes #13585.

  src/leveldb/build_detect_platform shows how upstream defines them.

  These platform may not be able to fully build or run Bitcoin Core, but defining all known to leveldb saves future hassle.

  Now that all possible platforms are enumerated, specifying an unknown one is an error.

Tree-SHA512: 89adfb8867248e50d713cb84485c72a398df8b2af467599cf292132342b5b47f01be3a298ca33e382e210004123aa72a6338bc911d38d40d8ceaef5083e0b025
2018-07-13 19:35:18 -07:00
Pieter Wuille
d6b2235ca4
Merge #13630: Drop unused pindexRet arg to CMerkleTx::GetDepthInMainChain
d6f39b6c64 Drop unused pindexRet arg to CMerkleTx::GetDepthInMainChain (Ben Woosley)

Pull request description:

Tree-SHA512: 5f064a47e71113f90f296ab36dae92173ff3fc632ab4e1e85dc71d556cb9239d15939b1e542f4292dab93d336795b7f2e4ae64f6984303c852df8d24f54ccebe
2018-07-13 19:33:41 -07:00
Andrew Chow
8b5ef27937 SignPSBTInput wrapper function
The SignPSBTInput function takes a PSBTInput, SignatureData, SigningProvider,
and other data necessary for signing. It fills the SignatureData with data from
the PSBTInput, retrieves the UTXO from the PSBTInput, signs and finalizes the
input if possible, and then extracts the results from the SignatureData and
puts them back into the PSBTInput.
2018-07-13 14:27:31 -07:00
Andrew Chow
58a8e28918 Refactor transaction creation and transaction funding logic
In preparation for more create transaction and fund transcation RPCs,
refactor the transaction creation and funding logic into separate
functions.
2018-07-13 14:27:31 -07:00
Andrew Chow
e9d86a43ad Methods for interacting with PSBT structs
Added methods which move data to/from SignaturData objects to
PSBTInput and PSBTOutput objects.

Added sanity checks for PSBTs as a whole which are done immediately
after deserialization.

Added Merge methods to merge a PSBT into another one.
2018-07-13 14:27:31 -07:00
Andrew Chow
12bcc64f27 Add pubkeys and whether input was witness to SignatureData
Stores pubkeys in SignatureData and retrieves them when using GetPubKey().

Stores whether the signatures in a SignatureData are for a witness input.
2018-07-13 14:27:31 -07:00
Andrew Chow
41c607f09b Implement PSBT Structures and un/serialization methods per BIP 174 2018-07-13 14:27:31 -07:00
Thomas Kerin
417b6c1d29 bitcoinconsensus: invalid flags should be set to bitcoinconsensus_error type, add test cases covering bitcoinconsensus error codes 2018-07-13 22:13:10 +01:00
MarcoFalke
8f1106da58
Merge #13626: qa: Fix some TODOs in p2p_segwit
eeeef80fb6 qa: Fix some TODOs in p2p_segwit (MarcoFalke)

Pull request description:

  * I believe we don't need to redundantly test versionbits logic in every functional tests that tests a softfork deployment that is being done with versionbits. Thus, remove two `TODO`s that ask for that.
  * Replace another `TODO` with `wait_until`.
  * Some style fixups after #13467

Tree-SHA512: c7120404d50579d6f3b9092f1e259959190eeafe520231e3479c8c256a50bf7260ccc93f8301ac0e100c54037053f6849433ebb1c55607e01d94b9812e525083
2018-07-13 17:08:19 -04:00
Cory Fields
768981c93d build: add missing leveldb defines
src/leveldb/build_detect_platform shows how upstream defines them.

These platform may not be able to fully build or run Bitcoin, but defining all
known to leveldb saves future hassle.

Now that all possible platforms are enumerated, specifying an unknown one is an
error.
2018-07-13 16:47:19 -04:00
Ben Woosley
17e6aa8e33
Privatize CWallet::AddToWalletIfInvolvingMe
And document in the header.
2018-07-13 16:18:14 -04:00
Ben Woosley
b7f5650942
Extract CWallet::MarkInputsDirty
To avoid repeated implementations.
2018-07-13 16:18:13 -04:00
MarcoFalke
eeeef80fb6
qa: Fix some TODOs in p2p_segwit 2018-07-13 16:14:44 -04:00
Jonas Schnelli
619cd29393
Merge #12944: [wallet] ScanforWalletTransactions should mark input txns as dirty
3c292cc19 ScanforWalletTransactions should mark input txns as dirty (Gregory Sanders)

Pull request description:

  I'm hitting a corner case in my mainnet wallet where I load a restore a wallet, call `rescanblockchain` from RPC, and it's "double counting" an output I've sent to myself since currently it never marks input transactions as dirty. This is fixed by a restart of the wallet.

  Note that this only happens with keys with birthdate *after* the blocks containing the spent funds which gets scanned on startup, so it's hard to test without a set seed function.

Tree-SHA512: ee1fa152bb054b57ab4c734e355df10d241181e0372c81d583be61678fffbabe5ae60b09b05dc1bbbcfb4838df9d8538791d4c1d80a09b84d78ad2f50dcb0a61
2018-07-13 20:34:43 +01:00
Ben Woosley
89e70f9d7f
Fix that CWallet::AbandonTransaction would only traverse one level
Prior to this change, it would mark only the first layer of
child transactions abandoned, due to always following the input hashTx
rather than the current now tx.
2018-07-13 11:16:08 -04:00
MarcoFalke
2ea7eb62b2
Merge #13645: [tests] skip rpc_zmq functional test as necessary
a0b604c166 [tests] skip rpc_zmq functional test when python3 zmq lib is not present (James O'Beirne)

Pull request description:

  As noted in https://github.com/bitcoin/bitcoin/pull/13570/files#r201715904, the `rpc_zmq` functional test should be skipped when the `zmq` python3 package is not installed. This is breaking https://bitcoinperf.com benchmarks at the moment.

Tree-SHA512: ab519ae717f4b7a282640cf0389651723fdc108990aeb9852e8b9e96d61fa1ded2461717ae31558b37ff8401a5b1ccc41f4e858e402b8c3d98563d962599767a
2018-07-13 05:58:20 -04:00
Ben Woosley
5617840392
Drop dead code from Stacks
Stacks is local to this file, and only used in DataFromTransaction, so
it's easy to confirm this code is unused.
2018-07-12 18:44:33 -04:00
Jonas Schnelli
a3fa4d6a6a
QA: Fix bug in -usecli logic that converts booleans to non-lowercase strings 2018-07-12 20:32:07 +01:00