Skip to content

Instantly share code, notes, and snippets.

View DrSammyD's full-sized avatar

Sam Armstrong DrSammyD

View GitHub Profile
@DrSammyD
DrSammyD / 0-Confirmation-Double-Spend-Protocol.md
Last active January 30, 2022 00:06
A double-spend protocol to make 0-confirmation transactions secured by consensus rules.

0-Confirmation Double-Spend Protocol

The problem

Bitcoin-accepting merchants want to receive payment and provide services instantly. However, block construction times can be as much as 10 minutes after the moment a bitcoin transaction is broadcast. In the time after a transaction but before a block’s creation, that transaction can be superseded by another transaction with a larger fee paid to miners.

With the change in the mempool protocol from first-seen-first-included and the rejection of conflicting double spends, to the inclusion of double spends and prioritizing transactions with larger fees attached, 0-conf transactions can no longer be reasonably secure for any sized transaction.

The idea of replace-by-fee was that miners will follow their immediate self-interest, and if miners sporadically act that way, could potentially decrease trust in the system. Now that this approach has been assumed and is the default behavior of miner software, we might consider amending t

@DrSammyD
DrSammyD / EntityExpressionCopy.cs
Last active February 12, 2019 21:02
An expression generator to deep copy entities from one type to another, preserving reference loops.
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace EntityExpressionCopy
{
@DrSammyD
DrSammyD / underscore.resolveRelink.js
Last active April 23, 2018 11:49
A lodash mixin which will create an object that links and unlinks circular references based on the way json.net handles reference loops. Based on this Stackoverflow answer http://stackoverflow.com/a/21687071/364282
@DrSammyD
DrSammyD / koSelectizeBinding.js
Last active July 6, 2016 13:07
Selectize Binding Handler
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['knockout','jquery','selectize'], factory);
} else {
var selConstructor = (typeof selectize != "undefined")?selectize:$('<select>').selectize().data('selectize').constructor;
factory(ko,$,selConstructor);
}
})(function (ko,$,selectize) {
@DrSammyD
DrSammyD / jq.domcallback.coffee
Created March 1, 2013 02:08
jquery plugin that provides a way to notify parents of different types of callbacks defined by the plugin user
(($, window) ->
hasArgs = () -> arguments.length > 0
noArgs = () -> arguments.length == 0
class DomCallbacks
###*
* Defines the jQuery functions to create callbacks for, and which type of callback they contain
* @type {defaults}
* @properties {array of jQuery function names, and test to determine if the callback
* should be run based on input to the jQuery function, passed the same arguments that the jQuery
* function is}
@DrSammyD
DrSammyD / ko.jqhtml.coffee
Created March 1, 2013 02:07
knockout binding handler using custom jquery domcallback plugin
ko.bindingHandlers.jqHtml =
init: (element, valueAccessor) ->
$(element).preMutate (options, el) ->
if ko.isObservable valueAccessor()
valueAccessor().valueWillMutate()
$(element).onMutate _.debounce (argsCollection) =>
@argsCollection = argsCollection
if ko.isObservable valueAccessor()
valueAccessor().valueHasMutated()
, 100
@DrSammyD
DrSammyD / underscore.debounce
Created March 1, 2013 02:03
underscore debounce wich gives all the arguments called against the function to the function
_.debounceAll = (func, wait, immediate) ->
timeout = undefined
result = undefined
results = []
->
results.push
context: this
args: for val in arguments
val
@DrSammyD
DrSammyD / ROA.c
Created October 22, 2015 15:05
Rivals of Aether gpc program
/* *
* GPC SCRIPT
*
* GPC is a scripting language with C-like syntax.
* To learn more access GPC Language Reference on Help menu.
* *********************************************************** */
define LP = XB360_X;
define LK = XB360_A;
define MP = XB360_Y;
@DrSammyD
DrSammyD / repeat.js
Created December 8, 2014 23:19
function which repeats an id a set amount of times and then increments
var repeat= function(reps){
var repeatOrig=ko.repeat;
repeatOrig.uid=!repeatOrig.uid?1:repeatOrig.uid+1;
var times = reps-1;
var repetion= function(){
if(--times<=0)
ko.repeat=repeatOrig;
return repeatOrig.uid;
};
ko.repeat=repetion;
@DrSammyD
DrSammyD / resolveRelink.js
Last active August 29, 2015 14:09
Track using knockout es5 recursively