This commit contains rather hard to review diffs to the protobuf test datasets in .txt format.
To aid the review, this Python script can be used to convert the data from the old to the new
format:
```
import sys
file = open(sys.argv[1])
outfile = open(sys.argv[1] + ".lite", "w")
line = file.readline()
lines = []
def sortAndPrint(group, removeLastLB=False, removeFirstLB=False):
group.sort()
if removeFirstLB and group[0] == "\n":
group.remove("\n")
for i in range(len(group)):
if i == len(group) - 1 and removeLastLB:
group[i] = group[i].rstrip()
print(group[i], end="", file=outfile)
def sign32neg(value):
if 0x80000000 <= value <= 0xFFFFFFFF:
value &= 0x7FFFFFFF
value = int(value)
value = ~value
value ^= 0x7FFFFFFF
return value
def processPath(path):
parts = path.rstrip().split(":")
number = int(parts[1].lstrip())
if number >= 0x80000000:
number = sign32neg(number)
return parts[0] + ": " + str(number) + "\n"
groupcount = 0
while len(line) > 0:
if line.startswith("type:"):
if len(lines):
sortAndPrint(lines, removeFirstLB=groupcount==0)
groupcount += 1
lines.clear()
lines.append(line)
elif line.find("deterministic_key {") != -1:
structure = line
innerlines = []
line = file.readline()
while not line.startswith('}'):
if line.find("path") != -1: # preserve order of paths
pathlines = processPath(line)
line = file.readline()
if line.startswith('}'):
innerlines.append(pathlines)
continue
while line.find("path") != -1:
pathlines += processPath(line)
line = file.readline()
innerlines.append(pathlines)
if line.startswith('}'):
continue
if line.startswith(" sigsRequiredToSpend"):
line = line.replace("sigsRequiredToSpend", "sigs_required_to_spend")
innerlines.append(line)
line = file.readline()
innerlines.sort()
for l in innerlines:
structure += l
structure += line.rstrip() + "\n"
lines.append(structure)
elif line.find("path") != -1: # preserve order of paths
accountpathlines = processPath(line)
line = file.readline()
while line.find("path") != -1:
accountpathlines += processPath(line)
line = file.readline()
lines.append(accountpathlines)
lines.append(line)
else:
lines.append(line)
line = file.readline()
print(file=outfile)
sortAndPrint(lines, removeLastLB=True)
file.close()
outfile.close()
```
- Hierarchical-deterministic derivation of native segwit addresses.
- Receive payments to native segwit addresses.
- Spend and sign payments from native segwit addresses.
- Watch-only wallets with native segwit addresses (zpub/vpub).
- WalletAppKit, Wallet-tool and Wallet-template are taught to deal with segwit-enabled wallets.
Be aware this adds a new field in the wallet protobuf: output_script_type in Key, which keeps track
of the script type of DeterministicKeyChains. Protobufs will be migrated; old DeterministicKeyChains
are assumed to be of type P2PKH.
Includes some code by Fabrice Drouin.
The goal of this commit is to fix loading blk*.dat files by BlockFileLoader. Bitcoinj cannot yet
create segwit transactions nor does it correctly process them.
Based on code by:
NicolasDorier <nicolas.dorier@gmail.com>
Oscar Guindzberg <oscar.guindzberg@gmail.com>
sstone <sstone@users.noreply.github.com>
In the test data for DeterministicKeyChainTest all occurences of the (often invisible) 0x7f
character is replaced by its numerical literal "\177". This change is needed because a bug of
previous versions was fixed, which caused this character not being printed as text.
This also synchs script_tests.json to Bitcoin Core's version as of dde46d3ae1de18700e089bc1861cf1e18649dc5d, minus some of the newer 'invalid' tests which we can't handle yet.
We also need to check 'invalid' tests more specificly for the expected error; the current behaviour mimics how dataDrivenInvalidScripts() used to work.
The buildCreditingTransaction() and buildSpendingTransaction() methods were written by Nicola Atzei.
This replaces the limited script number encoder previously used for block
height with a version that matches the exact format generated by Bitcoin
Core (which can include an additional byte for sign in some cases).
With thanks to Kalpesh Parmar for pointing out that some blocks on the
testnet have coinbase transactions with height encoded in 2 bytes.
Add script verification flags for DER format encoding, low-S signatures
and strict encoding.
Pass script verification flags through to signature parser.
Convert block verification flags to a sub-enum of Block.
Remove DER signature format verification flag from block flags.
Add test transaction with a non-standard DER signature, with the verify
flag set/unset accordingly, to tx_invalid.json and tx_valid.json
Original submission:
```
commit 1c54757f8678c9131ec55c128b8f1d5b6c73c2f9
Author: Dave Collins <davec@conformal.com>
Date: Wed May 6 10:16:18 2015 -0500
Add more script edge condition tests.
This commit adds some tests to the script_valid.json and tx_invalid.json
data which exercise more edge conditions that are not currently being
tested.
```
Via:
https://github.com/bitcoin/bitcoin/pull/6112
* move handling of following keychains into the leading keychain
* move multisig threshold into the leading keychain
* extract MarriedKeyChain from DeterministicKeyChain
Previously the codepath that was supposed to mark keys as used didn't work, and the lookahead calculation wasn't quite right. Now the current key advances correctly when an inbound tx is found that spends to it, including pending transactions. Additionally the lookahead zone now has the threshold zone after it, not inside it, meaning that if you request a lookahead size of 100 keys you'll actually always have at least 100 keys, never less.