From 4637ae9362037e16e3703b246c54c4de207f44d5 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Thu, 23 May 2019 03:14:49 +0200 Subject: [PATCH] Pre release (#20) * Sign executables on deploy * Use human readable version of addresses in bloom filters. * Make sure transactions and addresses are always updated --- bitcoin/phored/datastore.go | 6 +++--- bitcoin/phored/notify.go | 3 +++ bitcoin/phored/wallet.go | 9 ++++++--- deploy.sh | 15 +++++++++++++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/bitcoin/phored/datastore.go b/bitcoin/phored/datastore.go index f74af43b9b..4491869e87 100644 --- a/bitcoin/phored/datastore.go +++ b/bitcoin/phored/datastore.go @@ -71,12 +71,12 @@ func (ts *TxStore) GimmeFilter() (*bloom.Filter, error) { } ts.addrMutex.Lock() elem := uint32(len(ts.adrs)+len(allUtxos)+len(allStxos)) + uint32(len(ts.watchedScripts)) - f := bloom.NewFilter(elem, 0, 0.00003, wire.BloomUpdateAll) + f := bloom.NewFilter(elem, 0, 0.001, wire.BloomUpdateAll) // note there could be false positives since we're just looking // for the 20 byte PKH without the opcodes. for _, a := range ts.adrs { // add 20-byte pubkeyhash - f.Add(a.ScriptAddress()) + f.Add([]byte(a.EncodeAddress())) log.Debugf("bloom filter - watching for addr %s\n", a.String()) } ts.addrMutex.Unlock() @@ -94,7 +94,7 @@ func (ts *TxStore) GimmeFilter() (*bloom.Filter, error) { continue } log.Debugf("bloom filter - watching for addrs %s from script (class - %s)", addrs, scriptClass.String()) - f.Add(addrs[0].ScriptAddress()) + f.Add([]byte(addrs[0].EncodeAddress())) } return f, nil diff --git a/bitcoin/phored/notify.go b/bitcoin/phored/notify.go index e799416148..37db84ade4 100644 --- a/bitcoin/phored/notify.go +++ b/bitcoin/phored/notify.go @@ -95,6 +95,9 @@ func startNotificationListener(wallet *RPCWallet) (*NotificationListener, error) if err != nil { log.Errorf("Reconnection failed. %s", err) } + // if disconnected try to download transactions again and subscribe to bloom + wallet.RetrieveTransactions() + notificationListener.updateFilterAndSend() } } }() diff --git a/bitcoin/phored/wallet.go b/bitcoin/phored/wallet.go index 33ed95ee5a..ed9cf3a0cc 100644 --- a/bitcoin/phored/wallet.go +++ b/bitcoin/phored/wallet.go @@ -260,7 +260,7 @@ func (w *RPCWallet) ChildKey(keyBytes []byte, chaincode []byte, isPrivateKey boo return hdKey.Child(0) } -// Mnemonic returns the mnemonis used to generate the wallet +// Mnemonic returns the mnemonic used to generate the wallet func (w *RPCWallet) Mnemonic() string { return w.mnemonic } @@ -494,8 +494,11 @@ func (w *RPCWallet) addWatchedScript(addr btc.Address) error { // ReSyncBlockchain resyncs the addresses used by the SPV wallet func (w *RPCWallet) ReSyncBlockchain(fromDate time.Time) { - w.txstore.PopulateAdrs() - w.RetrieveTransactions() + if w.started { + w.txstore.PopulateAdrs() + w.RetrieveTransactions() + w.notifications.updateFilterAndSend() + } } // Close closes the rpc wallet connection diff --git a/deploy.sh b/deploy.sh index 2f48d7f841..0d4788983f 100755 --- a/deploy.sh +++ b/deploy.sh @@ -12,6 +12,21 @@ if [ ! -z "$TRAVIS_TAG" ] && cp ../.travis/win32/libwinpthread-1.dll libwinpthread-1.win32.dll cp ../.travis/win64/libwinpthread-1.dll libwinpthread-1.win64.dll + # Calculate SHA512 hashes + sha512sum * > sha512_checksums.txt + + # Load signing key + cp ../.travis/sign.key.gpg /tmp + gpg --yes --batch --passphrase=$GPG_PASS /tmp/sign.key.gpg + gpg --allow-secret-key-import --import /tmp/sign.key.gpg + rm /tmp/sign.key.gpg + + # Sign hash file + gpg --clearsign --digest-algo SHA512 --armor --output sha512_checksums.asc --passphrase=$GPG_PASS --default-key $GPG_KEYID sha512_checksums.txt + + rm sha512_checksums.txt + + # Upload to GitHub Release page ghr --username phoreproject -t $GITHUB_TOKEN --replace --prerelease --debug $TRAVIS_TAG . else