Skip to content

Instantly share code, notes, and snippets.

View gist:5315954b7f7bf6735a60c2248de23b23
class Database extends Jig {
get(key) { return this[key] }
set(key, value) { this[key] = value }
}
class MemDatabase {
constructor() { this.database = new Database(); this.kv = {} }
load() { this.kv = this.database.get('db') }
save() { this.database.set('db', this.kv) }
get(key) { return this.kv[key] }
View x.cpp
diff --git a/src/gtest/test_checktransaction.cpp b/src/gtest/test_checktransaction.cpp
index 76d50b8..704be83 100644
--- a/src/gtest/test_checktransaction.cpp
+++ b/src/gtest/test_checktransaction.cpp
@@ -513,14 +513,14 @@ TEST(checktransaction_tests, OverwinterExpiryHeight) {
}
{
- mtx.nExpiryHeight = TX_EXPIRY_HEIGHT_THRESHOLD;
+ mtx.nExpiryHeight = TX_EXPIRY_HEIGHT_THRESHOLD - 1;
@bitcartel
bitcartel / gist:86ca316b74f0b1ec6d8de3ac132006da
Created Jun 12, 2017
(1) zaddr -> taddr + zaddr (2) zaddr -> taddr
View gist:86ca316b74f0b1ec6d8de3ac132006da
2017-06-12 05:39:44 opid-e48e83de-d003-4069-b69c-defc841465c3: z_sendmany initialized (params={"fromaddress":"ztr4Ef2m7CFTtTvs4UpDz8zJY4Swukr3NRKThfLE12sNdGdav7Yf55G9HMAzGM3baR1FD43u9jb5JsAN67BBvz1UsVdLxoi","amounts":[{"address":"tmFX9rSJZVsti5a5ZYd2vfs1uVbxhX5Cyjg","amount":80.0},{"address":"tmNAfAgiY4wLhYkke7VxMcAUzFcfwnZz6SV","amount":8.88},{"address":"zteAQyrFfrKtN7GfGYzMBAKVA57JKHDmgXdLdgkYfXKD31ftPgsCR6KQ4zmBvZuDvkXZd1nwfv5UjFeDYZCcDtJHp62E7iZ","amount":1.2345},{"address":"ztbJeEwofNn5WfSh4e6enUUWUtsySLkbuubS2zX9jU45KGWTAxsJrVEhQo2PjQsGYSej1N3KXX5E7FzJyeQQMZdbQSdxupe","amount":1.2345}],"minconf":1,"fee":0.0001})
2017-06-12 05:39:44 opid-e48e83de-d003-4069-b69c-defc841465c3: found unspent note (txid=d6469443de, vjoinsplit=0, ciphertext=0, amount=15.6249, memo=f600000000)
2017-06-12 05:39:44 opid-e48e83de-d003-4069-b69c-defc841465c3: found unspent note (txid=0f9e8e39e9, vjoinsplit=0, ciphertext=0, amount=12.4999, memo=f600000000)
2017-06-12 05:39:44 opid-e48e83de-d003-4069-b69c-defc841465c3: found unspent
View gist:8f1c909c020ce4e076e22aeddaaf98d1
====
zrpc
====
taddr -> zaddr
2017-02-07 07:51:46 opid-2c49160c-7447-4384-8611-f34f48ace5ee: z_sendmany initialized
2017-02-07 07:51:46 opid-2c49160c-7447-4384-8611-f34f48ace5ee: spending 12.50 to send 12.4999 with fee 0.0001
2017-02-07 07:51:46 opid-2c49160c-7447-4384-8611-f34f48ace5ee: transparent input: 12.50 (to choose from)
2017-02-07 07:51:46 opid-2c49160c-7447-4384-8611-f34f48ace5ee: transparent output: 0.00
2017-02-07 07:51:46 opid-2c49160c-7447-4384-8611-f34f48ace5ee: fee: 0.0001
View gist:c17e41788d314223bb5db01662344bf1
zrpc from taddr:
2017-02-06 21:15:39 opid-ee5feb43-7880-4544-b76f-4b500b585e56: z_sendmany initialized
2017-02-06 21:15:39 opid-ee5feb43-7880-4544-b76f-4b500b585e56: spending 12.50 to send 12.4999 with fee 0.0001
2017-02-06 21:15:39 opid-ee5feb43-7880-4544-b76f-4b500b585e56: - transparent input: 12.50 (to choose from)
2017-02-06 21:15:39 opid-ee5feb43-7880-4544-b76f-4b500b585e56: - private input: 0.00 (to choose from)
2017-02-06 21:15:39 opid-ee5feb43-7880-4544-b76f-4b500b585e56: - transparent output: 0.00
2017-02-06 21:15:39 opid-ee5feb43-7880-4544-b76f-4b500b585e56: - private output: 12.4999
2017-02-06 21:15:39 opid-ee5feb43-7880-4544-b76f-4b500b585e56: - fee: 0.0001
2017-02-06 21:15:39 opid-ee5feb43-7880-4544-b76f-4b500b585e56: creating joinsplit at index 0 (vpub_old=12.4999, vpub_new=0.00, in[0]=0.00, in[1]=0.00, out[0]=12.4999, out[1]=0.00)
@bitcartel
bitcartel / patch.txt
Created Oct 4, 2016
patch so tests pass
View patch.txt
diff --git a/qa/rpc-tests/wallet.py b/qa/rpc-tests/wallet.py
index f0f7c8c..7f9541f 100755
--- a/qa/rpc-tests/wallet.py
+++ b/qa/rpc-tests/wallet.py
@@ -233,10 +233,7 @@ class WalletTest (BitcoinTestFramework):
assert_equal(self.nodes[2].z_getbalance(mytaddr), Decimal('10.0'));
# add zaddr to node 2
- # payment address: tneMWwNSjPkPaz7p5ed3XJbrz8XwpfBvaha3jaGU26EstNN8HKMYVyzgwMmVcmtaw7b5uuaF4Hr8P4UPZEMkuTkXQa8STzF
- # spending key: TKWRfN47drnaFDbHBSYT2McbPjbmFjjTrGuntj3tAMnnGDg2Kp19
@bitcartel
bitcartel / alert.cpp
Created Jul 15, 2016 — forked from lukem512/alert.cpp
Generate Alert Tests in Bitcoin Core (SignAndSave alternative)
View alert.cpp
// Sign CAlert with stored private key
bool SignAlert(CAlert &alert)
{
// key in WIF format
const char* pszPrivKey = "";
// serialize alert data
CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION);
sMsg << *(CUnsignedAlert*)&alert;
alert.vchMsg = std::vector<unsigned char>(sMsg.begin(), sMsg.end());
View gist:6f2a9947b1003c328744119185c40317

How to test bitcoin alerts

Motivation

Programming for bitcoin can be a bit of a pain at times. There's a lot of esoteric knowledge required and not everything is documented that well, though with some of the newer documentation projects like the [bitcoin developer documentation][devdocs], it's getting easier.

One thing I ran into recently is the existence of bitcoin alerts. These are alerts that are sent by the core developers onto the entire bitcoin network to warn of serious security events. They don't come up very often (there's [only been 8][alertlist] in the entire history of bitcoin as of this writing), but if your application is built on top of it, you'd better handle it.

The problem, though, is that the alerts are actually signed by a key controlled by the core developers. You can't just create new alerts for testnet, for example, as every other bitcoin client, including your own, will ignore them. So how do you test them?

@bitcartel
bitcartel / sendalert.cpp
Created Jul 15, 2016 — forked from gavinandresen/sendalert.cpp
Bitcoin CAlert code (without private key, of course)
View sendalert.cpp
#include "headers.h"
#include "net.h"
static const int64 DAYS = 24 * 60 * 60;
void ThreadSendAlert();
class CSendAlert
{
public:
View gist:8ee7d7a495fb400c9807342b3bff1932
./src/zcash-cli listunspent
[
{
"txid" : "e5c9f4fb308c4ffc09b8db503e300ddf7ddf04495947977d1fe83acb3ef76e30",
"vout" : 0,
"address" : "n2EKawUowF2VQoL4vBuCNtBq62PF8v4VUE",
"scriptPubKey" : "21037162eb269d013b0917c13c6311f1a641c22b3b3b4453995dd96e136c2b60ef80ac",
"amount" : 0.59700000,
"confirmations" : 2743,
"spendable" : true