bitcoin-s/docs/next/core/dlc/index.html

266 lines
661 KiB
HTML
Raw Normal View History

<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Discreet Log Contract Data Structures · bitcoin-s</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta name="generator" content="Docusaurus"/><meta name="description" content="Bitcoin-S now has support for the basic data structures and algorithms involved in the setup and execution of Discreet Log Contracts (DLCs) in the package `org.bitcoins.core.protocol.dlc` as well as basic TLV format and LN Message format support at `org.bitcoins.core.protocol.tlv` which can be useful for many off-chain protocols including DLCs and Lightning."/><meta name="docsearch:version" content="next"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="Discreet Log Contract Data Structures · bitcoin-s"/><meta property="og:type" content="website"/><meta property="og:url" content="https://bitcoin-s.org/"/><meta property="og:description" content="Bitcoin-S now has support for the basic data structures and algorithms involved in the setup and execution of Discreet Log Contracts (DLCs) in the package `org.bitcoins.core.protocol.dlc` as well as basic TLV format and LN Message format support at `org.bitcoins.core.protocol.tlv` which can be useful for many off-chain protocols including DLCs and Lightning."/><meta property="og:image" content="https://bitcoin-s.org/img/undraw_online.svg"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://bitcoin-s.org/img/undraw_tweetstorm.svg"/><link rel="shortcut icon" href="/img/favicon.ico"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-61958686-2', 'auto');
ga('send', 'pageview');
</script><link rel="stylesheet" href="/css/code-block-buttons.css"/><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script><script type="text/javascript" src="https://fonts.googleapis.com/css?family=Montserrat:500"></script><script type="text/javascript" src="https://www.googletagmanager.com/gtag/js?id=UA-61958686-2"></script><script type="text/javascript" src="/js/code-block-buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/favicon.ico" alt="bitcoin-s"/><h2 class="headerTitleWithLogo">bitcoin-s</h2></a><a href="/versions"><h3>next</h3></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/docs/next/core/core-intro" target="_self">Docs</a></li><li class=""><a href="/download" target="_self">Download</a></li><li class=""><a href="/api/org/bitcoins" target="_self">API</a></li><li class=""><a href="/help" target="_self">Help</a></li><li class="navSearchWrapper reactNavSearchWrapper"><input type="text" id="search_input_react" placeholder="Search" title="Search"/></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i></i><span>Core Module</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Getting Started</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/next/getting-started">Intro and Getting Started</a></li><li class="navListItem"><a class="navItem" href="/docs/next/bips">Supported BIPs</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Getting Setup</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/next/getting-setup">Getting Bitcoin-S installed on your machine</a></li><li class="navListItem"><a class="navItem" href="/docs/next/ui-setup">Installing the DLC Wallet UI</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Applications</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/next/applications/cli">CLI</a></li><li class="navListItem"><a class="navItem" href="/docs/next/applications/server">Application Server</a></li><li class="navListItem"><a class="navItem" href="/docs/next/applications/gui">GUI</a></li><li class="navListItem"><a class="navItem" href="/docs/next/applications/server-systemd">Systemd installation</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Chain</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/next/chain/chain">Blockchain Verification</a></li><li class="navListItem"><a class="navItem" href="/docs/next/chain/filter-sync">Syncing Blockfilters</a></li><li class="navListItem"><a class="navItem" href="/docs/next/chain/chain-query-api">Chain Query API</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Configuration</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/next/config/configuration">Application Configuration</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Core Module</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/next/core/core-intro">Core Module</a></li><li class="navListItem"><a class="navItem" href="/docs/next/core/addresses">Generating Addresses</a><
var coll = document.getElementsByClassName('collapsible');
var checkActiveCategory = true;
for (var i = 0; i < coll.length; i++) {
var links = coll[i].nextElementSibling.getElementsByTagName('*');
if (checkActiveCategory){
for (var j = 0; j < links.length; j++) {
if (links[j].classList.contains('navListItemActive')){
coll[i].nextElementSibling.classList.toggle('hide');
coll[i].childNodes[1].classList.toggle('rotate');
checkActiveCategory = false;
break;
}
}
}
coll[i].addEventListener('click', function() {
var arrow = this.childNodes[1];
arrow.classList.toggle('rotate');
var content = this.nextElementSibling;
content.classList.toggle('hide');
});
}
document.addEventListener('DOMContentLoaded', function() {
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
createToggler('#tocToggler', 'body', 'tocActive');
var headings = document.querySelector('.toc-headings');
headings && headings.addEventListener('click', function(event) {
var el = event.target;
while(el !== headings){
if (el.tagName === 'A') {
document.body.classList.remove('tocActive');
break;
} else{
el = el.parentNode;
}
}
}, false);
function createToggler(togglerSelector, targetSelector, className) {
var toggler = document.querySelector(togglerSelector);
var target = document.querySelector(targetSelector);
if (!toggler) {
return;
}
toggler.onclick = function(event) {
event.preventDefault();
target.classList.toggle(className);
};
}
});
</script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"><a class="edit-page-link button" href="https://github.com/bitcoin-s/bitcoin-s/blob/master/docs/core/dlc.md" target="_blank" rel="noreferrer noopener">Edit</a><h1 id="__docusaurus" class="postHeaderTitle">Discreet Log Contract Data Structures</h1></header><article><div><span><p>Bitcoin-S now has support for the basic data structures and algorithms involved in the setup and execution of Discreet Log Contracts (DLCs) in the package <code>org.bitcoins.core.protocol.dlc</code> as well as basic TLV format and LN Message format support at <code>org.bitcoins.core.protocol.tlv</code> which can be useful for many off-chain protocols including DLCs and Lightning.</p>
<p><strong>Please note that this code is experimental as the <a href="https://github.com/discreetlogcontracts/dlcspecs">DLC specification</a> is a work-in-progress and so this code is not stable and is subject to change. This means that the DLC code in the official release may be out-of-date and may conflict with other implementations' results.</strong></p>
<p>Let's now cover the main data structures and interfaces supported.</p>
<h2><a class="anchor" aria-hidden="true" id="dlcpayoutcurve"></a><a href="#dlcpayoutcurve" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>DLCPayoutCurve</h2>
<p><a href="https://github.com/bitcoin-s/bitcoin-s/blob/master/core/src/main/scala/org/bitcoins/core/protocol/dlc/DLCPayoutCurve.scala">DLCPayoutCurve.scala</a> provides an interface for serializing and evaluating payout curves for DLCs as specified in the <a href="https://github.com/discreetlogcontracts/dlcspecs/blob/c4fb12d95a4255eabb873611437d05b740bbeccc/PayoutCurve.md">Payout Curve Specification</a>. This file supports arbitrary polynomial interpolation.</p>
<p>To approximate a payout curve that is not a piecewise polynomial function, one may either propose a new kind of curve to the specification, or use approximation. For example by feeding <code>DLCPayoutCurve</code> a list of <code>PiecewisePolynomialEndpoint</code>s, one receives a linear approximation of their payout curve which takes the sampled points and &quot;connects the dots&quot; with straight lines. Alternatively one can use spline interpolation and sample two midpoints of every spline to get a piecewise cubic interpolation.</p>
<pre><code class="hljs css language-scala"><span class="hljs-comment">// Constructing a forward contract's payout curve (going long) that looks like this:</span>
<span class="hljs-comment">// ________________</span>
<span class="hljs-comment">// /</span>
<span class="hljs-comment">// /</span>
<span class="hljs-comment">// _____/</span>
<span class="hljs-comment">// Assume a 15 binary digit oracle</span>
<span class="hljs-keyword">val</span> maxVal = (<span class="hljs-number">1</span>L &lt;&lt; <span class="hljs-number">15</span>) - <span class="hljs-number">1</span>
<span class="hljs-comment">// maxVal: Long = 32767</span>
<span class="hljs-keyword">val</span> pts = <span class="hljs-type">Vector</span>(
<span class="hljs-type">PiecewisePolynomialEndpoint</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>),
<span class="hljs-type">PiecewisePolynomialEndpoint</span>(<span class="hljs-number">1000</span>, <span class="hljs-number">0</span>),
<span class="hljs-type">PiecewisePolynomialEndpoint</span>(<span class="hljs-number">2000</span>, <span class="hljs-number">1000</span>),
<span class="hljs-type">PiecewisePolynomialEndpoint</span>(maxVal, <span class="hljs-number">1000</span>)
)
<span class="hljs-comment">// pts: Vector[PiecewisePolynomialEndpoint] = Vector(PiecewisePolynomialEndpoint(0,0), PiecewisePolynomialEndpoint(1000,0), PiecewisePolynomialEndpoint(2000,1000), PiecewisePolynomialEndpoint(32767,1000))</span>
<span class="hljs-keyword">val</span> curve = <span class="hljs-type">DLCPayoutCurve</span>.polynomialInterpolate(pts,<span class="hljs-type">DLCSerializationVersion</span>.<span class="hljs-type">Beta</span>)
<span class="hljs-comment">// curve: DLCPayoutCurve = DLCPayoutCurve(IndexedSeq(OutcomePayoutConstant(OutcomePayoutPoint(outcome=0,payout=0),OutcomePayoutPoint(outcome=1000,payout=0)), OutcomePayoutLine(OutcomePayoutPoint(outcome=1000,payout=0),OutcomePayoutPoint(outcome=2000,payout=1000)), OutcomePayoutConstant(OutcomePayoutPoint(outcome=2000,payout=1000),OutcomePayoutPoint(outcome=32767,payout=1000))),Beta)</span>
<span class="hljs-comment">// Let's evalute the curve's values at varios points</span>
curve(<span class="hljs-number">500</span>)
<span class="hljs-comment">// res0: Satoshis = 0 sats</span>
curve(<span class="hljs-number">1500</span>)
<span class="hljs-comment">// res1: Satoshis = 500 sats</span>
curve(<span class="hljs-number">1667</span>)
<span class="hljs-comment">// res2: Satoshis = 667 sats</span>
curve(<span class="hljs-number">10000</span>)
<span class="hljs-comment">// res3: Satoshis = 1000 sats</span>
<span class="hljs-comment">// Now with rounding to the nearest 100</span>
<span class="hljs-keyword">val</span> roundTo100 = <span class="hljs-type">RoundingIntervals</span>(<span class="hljs-type">Vector</span>(<span class="hljs-type">IntervalStart</span>(<span class="hljs-number">0</span>, <span class="hljs-number">100</span>)))
<span class="hljs-comment">// roundTo100: RoundingIntervals = RoundingIntervals(Vector(IntervalStart(0,100)))</span>
curve(<span class="hljs-number">1667</span>, roundTo100)
<span class="hljs-comment">// res4: Satoshis = 700 sats</span>
<span class="hljs-comment">// Let's take a look at the pieces in this piece-wise polynomial</span>
curve.pieces
<span class="hljs-comment">// res5: OrderedDLCPayoutCurvePieces = IndexedSeq(OutcomePayoutConstant(OutcomePayoutPoint(outcome=0,payout=0),OutcomePayoutPoint(outcome=1000,payout=0)), OutcomePayoutLine(OutcomePayoutPoint(outcome=1000,payout=0),OutcomePayoutPoint(outcome=2000,payout=1000)), OutcomePayoutConstant(OutcomePayoutPoint(outcome=2000,payout=1000),OutcomePayoutPoint(outcome=32767,payout=1000)))</span>
<span class="hljs-comment">// And we can even see which component is used on a given outcome</span>
<span class="hljs-keyword">val</span> <span class="hljs-type">Indexed</span>(line1, _) = curve.componentFor(<span class="hljs-number">500</span>)
<span class="hljs-comment">// line1: DLCPayoutCurvePiece = OutcomePayoutConstant(OutcomePayoutPoint(outcome=0,payout=0),OutcomePayoutPoint(outcome=1000,payout=0))</span>
line1(<span class="hljs-number">500</span>)
<span class="hljs-comment">// res6: Satoshis = 0 sats</span>
<span class="hljs-keyword">val</span> <span class="hljs-type">Indexed</span>(line2, _) = curve.componentFor(<span class="hljs-number">1667</span>)
<span class="hljs-comment">// line2: DLCPayoutCurvePiece = OutcomePayoutLine(OutcomePayoutPoint(outcome=1000,payout=0),OutcomePayoutPoint(outcome=2000,payout=1000))</span>
line2(<span class="hljs-number">1667</span>)
<span class="hljs-comment">// res7: Satoshis = 667 sats</span>
<span class="hljs-keyword">val</span> <span class="hljs-type">Indexed</span>(line3, _) = curve.componentFor(<span class="hljs-number">10000</span>)
<span class="hljs-comment">// line3: DLCPayoutCurvePiece = OutcomePayoutConstant(OutcomePayoutPoint(outcome=2000,payout=1000),OutcomePayoutPoint(outcome=32767,payout=1000))</span>
line3(<span class="hljs-number">10000</span>)
<span class="hljs-comment">// res8: Satoshis = 1000 sats</span>
</code></pre>
<p>While many approaches result in higher fidelity to the original curve than linear approximation, usually it is the case that numeric contracts use <a href="https://github.com/bitcoin-s/bitcoin-s/blob/master/core/src/main/scala/org/bitcoins/core/protocol/dlc/RoundingIntervals.scala">Rounding</a> which dominates the error so that linear approximation is adequate.</p>
<h2><a class="anchor" aria-hidden="true" id="cetcalculator"></a><a href="#cetcalculator" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>CETCalculator</h2>
<p><a href="https://github.com/bitcoin-s/bitcoin-s/blob/master/core/src/main/scala/org/bitcoins/core/protocol/dlc/CETCalculator.scala">CETCalculator.scala</a> provides an interface to all Contract Execution Transaction (CET) set computations as specified in the <a href="https://github.com/discreetlogcontracts/dlcspecs/blob/c4fb12d95a4255eabb873611437d05b740bbeccc/CETCompression.md">CET Compression Specification</a> and the <a href="https://github.com/discreetlogcontracts/dlcspecs/blob/4fb01bc4e15865fa8323caf7e9cebb403b8116a5/MultiOracle.md">Multi-Oracle Specification</a>.</p>
<p>Of particular note, are the functions <code>computeCETs</code> and <code>computeMultiOracleCETsBinary</code> which compute the entire set of outcomes (corresponding to CETs) for a single oracle and multiple numeric oracles with a bounded difference allowed respectively.</p>
<p>Additionally the <code>combinations</code> function allows for the easy and correctly-ordered reduction of any <code>t-of-n</code> scheme to many <code>t-of-t</code> schemes.</p>
<pre><code class="hljs css language-scala"><span class="hljs-keyword">val</span> totalCollateral = <span class="hljs-type">Satoshis</span>(<span class="hljs-number">1000</span>)
<span class="hljs-comment">// totalCollateral: Satoshis = 1000 sats</span>
<span class="hljs-keyword">val</span> cetsNoRounding = <span class="hljs-type">CETCalculator</span>.computeCETs(base = <span class="hljs-number">2</span>, numDigits = <span class="hljs-number">15</span>, curve, totalCollateral, <span class="hljs-type">RoundingIntervals</span>.noRounding)
<span class="hljs-comment">// cetsNoRounding: Vector[CETCalculator.CETOutcome] = Vector(CETOutcome(Vector(0, 0, 0, 0, 0, 0),0 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 0),0 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 0),0 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 0),0 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 0),0 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0),0 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0),0 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1),1 sat), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0),2 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1),3 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0),4 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1),5 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0),6 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1),7 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0),8 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1),9 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0),10 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1),11 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0),12 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1),13 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0),14 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1),15 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0),16 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1),17 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0),18 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1),19 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0),20 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1),21 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0),22 sats), CETOutcome(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),23 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),24 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1),25 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0),26 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1),27 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0),28 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1),29 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0),30 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1),31 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0),32 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1),33 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0),34 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1),35 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0),36 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1),37 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0),38 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1),39 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0),40 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1),41 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0),42 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1),43 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0),44 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1),45 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0),46 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1),47 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0),48 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1),49 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1,
cetsNoRounding.length
<span class="hljs-comment">// res9: Int = 1012</span>
<span class="hljs-keyword">val</span> cetsWithRounding = <span class="hljs-type">CETCalculator</span>.computeCETs(base = <span class="hljs-number">2</span>, numDigits = <span class="hljs-number">15</span>, curve, totalCollateral, roundTo100)
<span class="hljs-comment">// cetsWithRounding: Vector[CETCalculator.CETOutcome] = Vector(CETOutcome(Vector(0, 0, 0, 0, 0),0 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0),0 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0),0 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0),0 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1),100 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1),100 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1),100 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 1, 0),100 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0),100 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0),100 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0),100 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0),100 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1),200 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 1, 0),200 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 1, 1, 0),200 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0),200 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1),300 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1),300 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1),300 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1),300 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 0, 0),300 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0),300 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0),300 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1),400 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1),400 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1),400 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 0, 1, 1),400 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 1, 0, 0),400 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0),400 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0),400 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1),500 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1),500 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1),500 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 0, 1, 1, 1),500 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0),500 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0),500 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0),500 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1),600 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1),600 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 0, 0, 1),600 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 0, 1, 0),600 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0),600 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0),600 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1),700 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1),700 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1),700 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 1, 0),700 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0),700 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0),700 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0),700 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1),800 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1),800 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 0, 1, 1, 1),800 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 1, 0, 0, 0),800 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0),800 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0),800 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0),800 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1),900 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1),900 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 1, 0, 1),900 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0),900 sats), CETOutcome(Vector(0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0),900 sats)
cetsWithRounding.length
<span class="hljs-comment">// res10: Int = 71</span>
</code></pre>
<pre><code class="hljs css language-scala"><span class="hljs-keyword">val</span> oraclesStr = <span class="hljs-type">Vector</span>(<span class="hljs-string">"Alice"</span>, <span class="hljs-string">"Bob"</span>, <span class="hljs-string">"Carol"</span>, <span class="hljs-string">"Dave"</span>, <span class="hljs-string">"Eve"</span>)
<span class="hljs-comment">// oraclesStr: Vector[String] = Vector(Alice, Bob, Carol, Dave, Eve)</span>
<span class="hljs-keyword">val</span> combinations = <span class="hljs-type">CETCalculator</span>.combinations(oraclesStr, threshold = <span class="hljs-number">3</span>)
<span class="hljs-comment">// combinations: Vector[Vector[String]] = Vector(Vector(Alice, Bob, Carol), Vector(Alice, Bob, Dave), Vector(Alice, Bob, Eve), Vector(Alice, Carol, Dave), Vector(Alice, Carol, Eve), Vector(Alice, Dave, Eve), Vector(Bob, Carol, Dave), Vector(Bob, Carol, Eve), Vector(Bob, Dave, Eve), Vector(Carol, Dave, Eve))</span>
</code></pre>
<pre><code class="hljs css language-scala"><span class="hljs-keyword">val</span> multiOracleCETsNoRounding = <span class="hljs-type">CETCalculator</span>.computeMultiOracleCETsBinary(
numDigits = <span class="hljs-number">15</span>,
curve,
totalCollateral,
<span class="hljs-type">RoundingIntervals</span>.noRounding,
maxErrorExp = <span class="hljs-number">5</span>,
minFailExp = <span class="hljs-number">3</span>,
maximizeCoverage = <span class="hljs-literal">false</span>,
numOracles = <span class="hljs-number">3</span>
)
<span class="hljs-comment">// multiOracleCETsNoRounding: Vector[CETCalculator.MultiOracleOutcome] = Vector(MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 0), Vector(0, 0, 0, 0, 0, 1, 0), Vector(0, 0, 0, 0, 0, 1, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 0), Vector(0, 0, 0, 0, 0, 1, 1, 0), Vector(0, 0, 0, 0, 0, 1, 1, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 1, 0), Vector(0, 0, 0, 0, 0, 1, 1, 1, 0), Vector(0, 0, 0, 0, 0, 1, 1, 1, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1,
multiOracleCETsNoRounding.length
<span class="hljs-comment">// res11: Int = 2560</span>
<span class="hljs-keyword">val</span> multiOracleCETsWithRounding = <span class="hljs-type">CETCalculator</span>.computeMultiOracleCETsBinary(
numDigits = <span class="hljs-number">15</span>,
curve,
totalCollateral,
roundTo100,
maxErrorExp = <span class="hljs-number">5</span>,
minFailExp = <span class="hljs-number">3</span>,
maximizeCoverage = <span class="hljs-literal">false</span>,
numOracles = <span class="hljs-number">3</span>
)
<span class="hljs-comment">// multiOracleCETsWithRounding: Vector[CETCalculator.MultiOracleOutcome] = Vector(MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1), Vector(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0)),0 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1)),100 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0)),100 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1)),100 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0)),100 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1)),100 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0)),100 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1)),100 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0)),100 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1)),100 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0)),100 sats), MultiOracleOutcome(Vector(Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1), Vector(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1)),100 sats), MultiOr
multiOracleCETsWithRounding.length
<span class="hljs-comment">// res12: Int = 287</span>
</code></pre>
<h2><a class="anchor" aria-hidden="true" id="oracleoutcome"></a><a href="#oracleoutcome" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>OracleOutcome</h2>
<p><a href="https://github.com/bitcoin-s/bitcoin-s/blob/master/core/src/main/scala/org/bitcoins/core/protocol/dlc/OracleOutcome.scala">OracleOutcome</a>s correspond one-to-one with DLC execution paths (and with CETs). An <code>OracleOutcome</code> contains information about which oracles signed what, but storing only the information actually used for DLC execution and not extra unneeded information such as what additional oracles signed.</p>
<p>This trait also exposes an endpoint to the aggregate signature point (aka adaptor point) corresponding to this outcome which is used during CET signing, as well as an endpoint to compute the aggregate nonce.</p>
<h2><a class="anchor" aria-hidden="true" id="dlcstatus"></a><a href="#dlcstatus" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>DLCStatus</h2>
<p><a href="https://github.com/bitcoin-s/bitcoin-s/blob/master/core/src/main/scala/org/bitcoins/core/protocol/dlc/DLCStatus.scala">DLCStatus.scala</a> contains the DLC state machine comprised of the states <code>[Offered, Accepted, Signed, Broadcasted, Confirmed, Claimed, RemoteClaimed, Refunded]</code> each of which contain all relevant P2P messages and on-chain transactions.</p>
<p>The <code>DLCStatus</code> object also contains many useful utility functions to extract and compute various things from a <code>DLCStatus</code> such as transaction ids and even computing the <a href="#OracleOutcome">OracleOutcome</a> and aggregate oracle signature from on-chain information in the case that one's remote counter-party initiates execution.</p>
<h2><a class="anchor" aria-hidden="true" id="contractinfo"></a><a href="#contractinfo" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>ContractInfo</h2>
<p><a href="https://github.com/bitcoin-s/bitcoin-s/blob/master/core/src/main/scala/org/bitcoins/core/protocol/dlc/ContractInfo.scala">ContractInfo</a> wraps a <a href="https://github.com/bitcoin-s/bitcoin-s/blob/master/core/src/main/scala/org/bitcoins/core/protocol/dlc/ContractDescriptor.scala">ContractDescriptor</a> and an <a href="https://github.com/bitcoin-s/bitcoin-s/blob/master/core/src/main/scala/org/bitcoins/core/protocol/dlc/OracleInfo.scala">OracleInfo</a> and provides the complete external-facing interface needed during DLC setup and execution. A <code>ContractInfo</code> fully determines a DLC up to the choice of public keys and funding UTXOs to be used. One of its most important functions is <code>allOutcomesAndPayouts</code> which computes the entire set of <a href="#OracleOutcome">OracleOutcome</a>s and their corresponding payouts. Most of its other functions utilize that set to do all sorts of things such as retrieving payouts or finding an outcome given <code>OracleSignatures</code>.</p>
<pre><code class="hljs css language-scala"><span class="hljs-keyword">val</span> descriptor = <span class="hljs-type">NumericContractDescriptor</span>(curve, numDigits = <span class="hljs-number">15</span>, roundTo100)
<span class="hljs-comment">// descriptor: NumericContractDescriptor = NumericContractDescriptor(DLCPayoutCurve(IndexedSeq(OutcomePayoutConstant(OutcomePayoutPoint(outcome=0,payout=0),OutcomePayoutPoint(outcome=1000,payout=0)), OutcomePayoutLine(OutcomePayoutPoint(outcome=1000,payout=0),OutcomePayoutPoint(outcome=2000,payout=1000)), OutcomePayoutConstant(OutcomePayoutPoint(outcome=2000,payout=1000),OutcomePayoutPoint(outcome=32767,payout=1000))),Beta),15,RoundingIntervals(Vector(IntervalStart(0,100))))</span>
<span class="hljs-keyword">val</span> announcements = <span class="hljs-number">0.</span>until(<span class="hljs-number">5</span>).toVector.map { _ =&gt;
<span class="hljs-keyword">val</span> oraclePrivKey = <span class="hljs-type">ECPrivateKey</span>.freshPrivateKey
<span class="hljs-keyword">val</span> nonces = <span class="hljs-number">0.</span>until(<span class="hljs-number">15</span>).toVector.map(_ =&gt; <span class="hljs-type">ECPrivateKey</span>.freshPrivateKey.schnorrNonce)
<span class="hljs-keyword">val</span> orderedNonces = <span class="hljs-type">OrderedNonces</span>.fromUnsorted(nonces)
<span class="hljs-type">OracleAnnouncementV0TLV</span>.dummyForKeys(oraclePrivKey, orderedNonces)
}
<span class="hljs-comment">// announcements: Vector[OracleAnnouncementTLV] = Vector(OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(14de721d7a6f555422b193edf5b1b6841a75fe3b51a486167eb74e983fa569af),FieldElement(11a43b2aa21267719f3bd5023342a3c8d06fed925eeaef4860a9e78585e66b7c),None),SchnorrPublicKey(e0dfdb6a938b5a601cd3b9e136d44ee1920b413c046dffbc6caaeab7a5e27fa9),OracleEventV0TLV(Vector(SchnorrNonce(02a73ac3e319f1215bca55e13692a3e36e64c15a7398a9aec1974976ca2b8e26), SchnorrNonce(1a59a51b125733a7f9ef3b5b26132919f760f5b727df2494be0f6fbd4347345f), SchnorrNonce(1d5be13e4ec6a1b9c1a07253a6118e76607676b9bdf4e971ad714583a737b0d5), SchnorrNonce(2ea107571158bd39cf5a210db462eddc2b765fed847bc6c02e70aadb8a622143), SchnorrNonce(5753ba966d45bf335b817733792a9105ac117faea015dafdee87912609766813), SchnorrNonce(82646a833ce8ae6e9a0dfde1b8b991c81dfc0b0b95a1e9dc184c6ee012a4e757), SchnorrNonce(99bdba3bef71066da9a50da78501cca6a79299bc937705a262a0d198e4f337bb), SchnorrNonce(af5d0c190200836e96ce95ab1241222934f9cf6f3ca6e8d608cbec3479b3de71), SchnorrNonce(b2cf5bf8c8de900e39f5a85d565656e373134e6545e9517c2869bf7d52532363), SchnorrNonce(ca39f5a5ff5194353ce507335c5f3be26c9cac0d3676d81866d89c12be099106), SchnorrNonce(cb86b6935365b39e86714ea7088aa0d42cf2bab32bff61b6958462c60f0d040c), SchnorrNonce(d950120c3100154d3347ab7b873f481b556eed93b2552a6654aa923aeeef6616), SchnorrNonce(daf054cf409639e744374fbe10817b63f63cd7d89b23f8126442294dc184ffef), SchnorrNonce(e7380a827fe985b98fe2c2af7bed45cf31fc8162a759d867b0a2fbc202dab918), SchnorrNonce(ec61e5dc505927f91e7fab6e6f82b1dd5fc93e13dd1a69e443b96ca2ff569124)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy)), OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(93dcef6ffa39b6d39df9ee37a8444bbe047aaf57c58770ec2b8c66b98e4db175),FieldElement(e4341dfdb1641a595a15d8e56012b6222c6b482c656926a27f9a8530d003342a),None),SchnorrPublicKey(8bcc9eb03dac6ce99c5f975423bd429262c03c265a0aa4360b3d85cfb1d050b6),OracleEventV0TLV(Vector(SchnorrNonce(04c602dcef23d87555ce01297e0885d17e8bcbbf6c052cfac600c66266969b1c), SchnorrNonce(153f9fdbad465103ee12062304d38020385c97d78cc11de1aa248ddecae9ce64), SchnorrNonce(25fc644073ba7dab06b547597403cf2396d5a79dedbe7055b5065933dd5c97be), SchnorrNonce(280efe4724c3ab0bbf88ff6c95511abfee3606f281f8679faeef905b809a9979), SchnorrNonce(4d433d7b041cdad542a9c8b3a6d2f30d7b4083d7d6dfedcc859c0449f21dd2d1), SchnorrNonce(51a1ff702993b3a4b438b9fbcc914f6f68835694521b542055e5a345d44c03f0), SchnorrNonce(562cc6f949110a1338a78ce60b90ab09929590bc5f8ebe03e3e1276f49dccb10), SchnorrNonce(6247fa183f1790e8b4176c7e44ba51c1fde8b3c70b5db2dbda9b3e27a0e2e95d), SchnorrNonce(9236f068cb7ee129c341e79b6b712ff749e7b0036cf26ed653129cef4846bdbd), SchnorrNonce(9dbd80bd38c0d625a9a81a02f8132c2bfea49bf39e1b998d66320bf54cefb16c), SchnorrNonce(9efb3fa9b636122f0d55e5a47c96cd0c0c1c3636ed1e9ad386643fce81dd43f7), SchnorrNonce(9fa1679870dd854ceec0e2c00336fc63053aeaf2dee7346d7d4b3ef4d35bbd06), SchnorrNonce(ab2ed6246b263a8c8884c257a15920419a2a9e08258fe46267d7e4cfe9e79abc), SchnorrNonce(dfdf9e30ecd17f74b8d77467848d21663ceb2388b2595ea5553cc4bded3b0da0), SchnorrNonce(f03c54b212fb3fe9b1db4506446d1330accddd54118b29e73978d7455fb7bfb2)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy)), OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(bf84a4c67814fbce3e4a0aae6aefa02e5c980290c8824425539581fc8f3af998),FieldElement(3ed4bae11feb46e7549a7a2fcf1d162485030a38a0524680263917a3d5ab57d4),None),SchnorrPublicKey(c3d625c28ba58cbbc90470d27185a2377031c0df30ee36545aaa732241bab02c),OracleEventV0TLV(Vector(SchnorrNonce(03d96c62d8778d7ad87d1bc029b063cbea3f5ad1e3c030469cfac1724cf4b300), SchnorrNonce(052052106369bf8c4e0711f7ca33675af14cc1df1576b15dfc0edde111c033b9), SchnorrNonce(1c9f92573b11acebad777f7d9639b4d3008501796ca17aec63c3bdc0fb70a679), SchnorrNonce(1ff48a14bce0e134dfe0da94bc4a22b81d4f879cb8568b0d5464fd2f0c311e40), SchnorrNonce(3440da9773b1d0dd9f6b18632e420c92da72c95551ed7dfb8f3c1d21f63f9cc4), SchnorrNonce(51f67cb829e24
<span class="hljs-keyword">val</span> oracleInfo = <span class="hljs-type">NumericMultiOracleInfo</span>(
threshold = <span class="hljs-number">3</span>,
announcements = <span class="hljs-type">OrderedAnnouncements</span>(announcements),
maxErrorExp = <span class="hljs-number">5</span>,
minFailExp = <span class="hljs-number">3</span>,
maximizeCoverage = <span class="hljs-literal">false</span>
)
<span class="hljs-comment">// oracleInfo: NumericMultiOracleInfo = NumericMultiOracleInfo(3,IndexedSeq(OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(14de721d7a6f555422b193edf5b1b6841a75fe3b51a486167eb74e983fa569af),FieldElement(11a43b2aa21267719f3bd5023342a3c8d06fed925eeaef4860a9e78585e66b7c),None),SchnorrPublicKey(e0dfdb6a938b5a601cd3b9e136d44ee1920b413c046dffbc6caaeab7a5e27fa9),OracleEventV0TLV(Vector(SchnorrNonce(02a73ac3e319f1215bca55e13692a3e36e64c15a7398a9aec1974976ca2b8e26), SchnorrNonce(1a59a51b125733a7f9ef3b5b26132919f760f5b727df2494be0f6fbd4347345f), SchnorrNonce(1d5be13e4ec6a1b9c1a07253a6118e76607676b9bdf4e971ad714583a737b0d5), SchnorrNonce(2ea107571158bd39cf5a210db462eddc2b765fed847bc6c02e70aadb8a622143), SchnorrNonce(5753ba966d45bf335b817733792a9105ac117faea015dafdee87912609766813), SchnorrNonce(82646a833ce8ae6e9a0dfde1b8b991c81dfc0b0b95a1e9dc184c6ee012a4e757), SchnorrNonce(99bdba3bef71066da9a50da78501cca6a79299bc937705a262a0d198e4f337bb), SchnorrNonce(af5d0c190200836e96ce95ab1241222934f9cf6f3ca6e8d608cbec3479b3de71), SchnorrNonce(b2cf5bf8c8de900e39f5a85d565656e373134e6545e9517c2869bf7d52532363), SchnorrNonce(ca39f5a5ff5194353ce507335c5f3be26c9cac0d3676d81866d89c12be099106), SchnorrNonce(cb86b6935365b39e86714ea7088aa0d42cf2bab32bff61b6958462c60f0d040c), SchnorrNonce(d950120c3100154d3347ab7b873f481b556eed93b2552a6654aa923aeeef6616), SchnorrNonce(daf054cf409639e744374fbe10817b63f63cd7d89b23f8126442294dc184ffef), SchnorrNonce(e7380a827fe985b98fe2c2af7bed45cf31fc8162a759d867b0a2fbc202dab918), SchnorrNonce(ec61e5dc505927f91e7fab6e6f82b1dd5fc93e13dd1a69e443b96ca2ff569124)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy)), OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(93dcef6ffa39b6d39df9ee37a8444bbe047aaf57c58770ec2b8c66b98e4db175),FieldElement(e4341dfdb1641a595a15d8e56012b6222c6b482c656926a27f9a8530d003342a),None),SchnorrPublicKey(8bcc9eb03dac6ce99c5f975423bd429262c03c265a0aa4360b3d85cfb1d050b6),OracleEventV0TLV(Vector(SchnorrNonce(04c602dcef23d87555ce01297e0885d17e8bcbbf6c052cfac600c66266969b1c), SchnorrNonce(153f9fdbad465103ee12062304d38020385c97d78cc11de1aa248ddecae9ce64), SchnorrNonce(25fc644073ba7dab06b547597403cf2396d5a79dedbe7055b5065933dd5c97be), SchnorrNonce(280efe4724c3ab0bbf88ff6c95511abfee3606f281f8679faeef905b809a9979), SchnorrNonce(4d433d7b041cdad542a9c8b3a6d2f30d7b4083d7d6dfedcc859c0449f21dd2d1), SchnorrNonce(51a1ff702993b3a4b438b9fbcc914f6f68835694521b542055e5a345d44c03f0), SchnorrNonce(562cc6f949110a1338a78ce60b90ab09929590bc5f8ebe03e3e1276f49dccb10), SchnorrNonce(6247fa183f1790e8b4176c7e44ba51c1fde8b3c70b5db2dbda9b3e27a0e2e95d), SchnorrNonce(9236f068cb7ee129c341e79b6b712ff749e7b0036cf26ed653129cef4846bdbd), SchnorrNonce(9dbd80bd38c0d625a9a81a02f8132c2bfea49bf39e1b998d66320bf54cefb16c), SchnorrNonce(9efb3fa9b636122f0d55e5a47c96cd0c0c1c3636ed1e9ad386643fce81dd43f7), SchnorrNonce(9fa1679870dd854ceec0e2c00336fc63053aeaf2dee7346d7d4b3ef4d35bbd06), SchnorrNonce(ab2ed6246b263a8c8884c257a15920419a2a9e08258fe46267d7e4cfe9e79abc), SchnorrNonce(dfdf9e30ecd17f74b8d77467848d21663ceb2388b2595ea5553cc4bded3b0da0), SchnorrNonce(f03c54b212fb3fe9b1db4506446d1330accddd54118b29e73978d7455fb7bfb2)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy)), OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(bf84a4c67814fbce3e4a0aae6aefa02e5c980290c8824425539581fc8f3af998),FieldElement(3ed4bae11feb46e7549a7a2fcf1d162485030a38a0524680263917a3d5ab57d4),None),SchnorrPublicKey(c3d625c28ba58cbbc90470d27185a2377031c0df30ee36545aaa732241bab02c),OracleEventV0TLV(Vector(SchnorrNonce(03d96c62d8778d7ad87d1bc029b063cbea3f5ad1e3c030469cfac1724cf4b300), SchnorrNonce(052052106369bf8c4e0711f7ca33675af14cc1df1576b15dfc0edde111c033b9), SchnorrNonce(1c9f92573b11acebad777f7d9639b4d3008501796ca17aec63c3bdc0fb70a679), SchnorrNonce(1ff48a14bce0e134dfe0da94bc4a22b81d4f879cb8568b0d5464fd2f0c311e40), SchnorrNonce(3440da9773b1d0dd9f6b18632e420c92da72c95551ed7dfb8f3c1d21f63f9cc4), Schnorr
<span class="hljs-keyword">val</span> contractInfo = <span class="hljs-type">SingleContractInfo</span>(totalCollateral, <span class="hljs-type">ContractOraclePair</span>.<span class="hljs-type">NumericPair</span>(descriptor, oracleInfo))
<span class="hljs-comment">// contractInfo: SingleContractInfo = SingleContractInfo(1000 sats,NumericPair(NumericContractDescriptor(DLCPayoutCurve(IndexedSeq(OutcomePayoutConstant(OutcomePayoutPoint(outcome=0,payout=0),OutcomePayoutPoint(outcome=1000,payout=0)), OutcomePayoutLine(OutcomePayoutPoint(outcome=1000,payout=0),OutcomePayoutPoint(outcome=2000,payout=1000)), OutcomePayoutConstant(OutcomePayoutPoint(outcome=2000,payout=1000),OutcomePayoutPoint(outcome=32767,payout=1000))),Beta),15,RoundingIntervals(Vector(IntervalStart(0,100)))),NumericMultiOracleInfo(3,IndexedSeq(OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(14de721d7a6f555422b193edf5b1b6841a75fe3b51a486167eb74e983fa569af),FieldElement(11a43b2aa21267719f3bd5023342a3c8d06fed925eeaef4860a9e78585e66b7c),None),SchnorrPublicKey(e0dfdb6a938b5a601cd3b9e136d44ee1920b413c046dffbc6caaeab7a5e27fa9),OracleEventV0TLV(Vector(SchnorrNonce(02a73ac3e319f1215bca55e13692a3e36e64c15a7398a9aec1974976ca2b8e26), SchnorrNonce(1a59a51b125733a7f9ef3b5b26132919f760f5b727df2494be0f6fbd4347345f), SchnorrNonce(1d5be13e4ec6a1b9c1a07253a6118e76607676b9bdf4e971ad714583a737b0d5), SchnorrNonce(2ea107571158bd39cf5a210db462eddc2b765fed847bc6c02e70aadb8a622143), SchnorrNonce(5753ba966d45bf335b817733792a9105ac117faea015dafdee87912609766813), SchnorrNonce(82646a833ce8ae6e9a0dfde1b8b991c81dfc0b0b95a1e9dc184c6ee012a4e757), SchnorrNonce(99bdba3bef71066da9a50da78501cca6a79299bc937705a262a0d198e4f337bb), SchnorrNonce(af5d0c190200836e96ce95ab1241222934f9cf6f3ca6e8d608cbec3479b3de71), SchnorrNonce(b2cf5bf8c8de900e39f5a85d565656e373134e6545e9517c2869bf7d52532363), SchnorrNonce(ca39f5a5ff5194353ce507335c5f3be26c9cac0d3676d81866d89c12be099106), SchnorrNonce(cb86b6935365b39e86714ea7088aa0d42cf2bab32bff61b6958462c60f0d040c), SchnorrNonce(d950120c3100154d3347ab7b873f481b556eed93b2552a6654aa923aeeef6616), SchnorrNonce(daf054cf409639e744374fbe10817b63f63cd7d89b23f8126442294dc184ffef), SchnorrNonce(e7380a827fe985b98fe2c2af7bed45cf31fc8162a759d867b0a2fbc202dab918), SchnorrNonce(ec61e5dc505927f91e7fab6e6f82b1dd5fc93e13dd1a69e443b96ca2ff569124)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy)), OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(93dcef6ffa39b6d39df9ee37a8444bbe047aaf57c58770ec2b8c66b98e4db175),FieldElement(e4341dfdb1641a595a15d8e56012b6222c6b482c656926a27f9a8530d003342a),None),SchnorrPublicKey(8bcc9eb03dac6ce99c5f975423bd429262c03c265a0aa4360b3d85cfb1d050b6),OracleEventV0TLV(Vector(SchnorrNonce(04c602dcef23d87555ce01297e0885d17e8bcbbf6c052cfac600c66266969b1c), SchnorrNonce(153f9fdbad465103ee12062304d38020385c97d78cc11de1aa248ddecae9ce64), SchnorrNonce(25fc644073ba7dab06b547597403cf2396d5a79dedbe7055b5065933dd5c97be), SchnorrNonce(280efe4724c3ab0bbf88ff6c95511abfee3606f281f8679faeef905b809a9979), SchnorrNonce(4d433d7b041cdad542a9c8b3a6d2f30d7b4083d7d6dfedcc859c0449f21dd2d1), SchnorrNonce(51a1ff702993b3a4b438b9fbcc914f6f68835694521b542055e5a345d44c03f0), SchnorrNonce(562cc6f949110a1338a78ce60b90ab09929590bc5f8ebe03e3e1276f49dccb10), SchnorrNonce(6247fa183f1790e8b4176c7e44ba51c1fde8b3c70b5db2dbda9b3e27a0e2e95d), SchnorrNonce(9236f068cb7ee129c341e79b6b712ff749e7b0036cf26ed653129cef4846bdbd), SchnorrNonce(9dbd80bd38c0d625a9a81a02f8132c2bfea49bf39e1b998d66320bf54cefb16c), SchnorrNonce(9efb3fa9b636122f0d55e5a47c96cd0c0c1c3636ed1e9ad386643fce81dd43f7), SchnorrNonce(9fa1679870dd854ceec0e2c00336fc63053aeaf2dee7346d7d4b3ef4d35bbd06), SchnorrNonce(ab2ed6246b263a8c8884c257a15920419a2a9e08258fe46267d7e4cfe9e79abc), SchnorrNonce(dfdf9e30ecd17f74b8d77467848d21663ceb2388b2595ea5553cc4bded3b0da0), SchnorrNonce(f03c54b212fb3fe9b1db4506446d1330accddd54118b29e73978d7455fb7bfb2)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy)), OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(bf84a4c67814fbce3e4a0aae6aefa02e5c980290c8824425539581fc8f3af998),FieldElement(3ed4bae11feb46e7549a7a2fcf1d162485030a38a0524680263917a3d5ab57d4),None),SchnorrPublicKey(c3d625c28ba58cbbc9047
contractInfo.totalCollateral
<span class="hljs-comment">// res13: Satoshis = 1000 sats</span>
contractInfo.allOutcomes.length
<span class="hljs-comment">// res14: Int = 2870</span>
<span class="hljs-keyword">val</span> signingOracles = oracleInfo.singleOracleInfos.take(<span class="hljs-number">3</span>)
<span class="hljs-comment">// signingOracles: Vector[NumericSingleOracleInfo] = Vector(NumericSingleOracleInfo(OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(14de721d7a6f555422b193edf5b1b6841a75fe3b51a486167eb74e983fa569af),FieldElement(11a43b2aa21267719f3bd5023342a3c8d06fed925eeaef4860a9e78585e66b7c),None),SchnorrPublicKey(e0dfdb6a938b5a601cd3b9e136d44ee1920b413c046dffbc6caaeab7a5e27fa9),OracleEventV0TLV(Vector(SchnorrNonce(02a73ac3e319f1215bca55e13692a3e36e64c15a7398a9aec1974976ca2b8e26), SchnorrNonce(1a59a51b125733a7f9ef3b5b26132919f760f5b727df2494be0f6fbd4347345f), SchnorrNonce(1d5be13e4ec6a1b9c1a07253a6118e76607676b9bdf4e971ad714583a737b0d5), SchnorrNonce(2ea107571158bd39cf5a210db462eddc2b765fed847bc6c02e70aadb8a622143), SchnorrNonce(5753ba966d45bf335b817733792a9105ac117faea015dafdee87912609766813), SchnorrNonce(82646a833ce8ae6e9a0dfde1b8b991c81dfc0b0b95a1e9dc184c6ee012a4e757), SchnorrNonce(99bdba3bef71066da9a50da78501cca6a79299bc937705a262a0d198e4f337bb), SchnorrNonce(af5d0c190200836e96ce95ab1241222934f9cf6f3ca6e8d608cbec3479b3de71), SchnorrNonce(b2cf5bf8c8de900e39f5a85d565656e373134e6545e9517c2869bf7d52532363), SchnorrNonce(ca39f5a5ff5194353ce507335c5f3be26c9cac0d3676d81866d89c12be099106), SchnorrNonce(cb86b6935365b39e86714ea7088aa0d42cf2bab32bff61b6958462c60f0d040c), SchnorrNonce(d950120c3100154d3347ab7b873f481b556eed93b2552a6654aa923aeeef6616), SchnorrNonce(daf054cf409639e744374fbe10817b63f63cd7d89b23f8126442294dc184ffef), SchnorrNonce(e7380a827fe985b98fe2c2af7bed45cf31fc8162a759d867b0a2fbc202dab918), SchnorrNonce(ec61e5dc505927f91e7fab6e6f82b1dd5fc93e13dd1a69e443b96ca2ff569124)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy))), NumericSingleOracleInfo(OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(93dcef6ffa39b6d39df9ee37a8444bbe047aaf57c58770ec2b8c66b98e4db175),FieldElement(e4341dfdb1641a595a15d8e56012b6222c6b482c656926a27f9a8530d003342a),None),SchnorrPublicKey(8bcc9eb03dac6ce99c5f975423bd429262c03c265a0aa4360b3d85cfb1d050b6),OracleEventV0TLV(Vector(SchnorrNonce(04c602dcef23d87555ce01297e0885d17e8bcbbf6c052cfac600c66266969b1c), SchnorrNonce(153f9fdbad465103ee12062304d38020385c97d78cc11de1aa248ddecae9ce64), SchnorrNonce(25fc644073ba7dab06b547597403cf2396d5a79dedbe7055b5065933dd5c97be), SchnorrNonce(280efe4724c3ab0bbf88ff6c95511abfee3606f281f8679faeef905b809a9979), SchnorrNonce(4d433d7b041cdad542a9c8b3a6d2f30d7b4083d7d6dfedcc859c0449f21dd2d1), SchnorrNonce(51a1ff702993b3a4b438b9fbcc914f6f68835694521b542055e5a345d44c03f0), SchnorrNonce(562cc6f949110a1338a78ce60b90ab09929590bc5f8ebe03e3e1276f49dccb10), SchnorrNonce(6247fa183f1790e8b4176c7e44ba51c1fde8b3c70b5db2dbda9b3e27a0e2e95d), SchnorrNonce(9236f068cb7ee129c341e79b6b712ff749e7b0036cf26ed653129cef4846bdbd), SchnorrNonce(9dbd80bd38c0d625a9a81a02f8132c2bfea49bf39e1b998d66320bf54cefb16c), SchnorrNonce(9efb3fa9b636122f0d55e5a47c96cd0c0c1c3636ed1e9ad386643fce81dd43f7), SchnorrNonce(9fa1679870dd854ceec0e2c00336fc63053aeaf2dee7346d7d4b3ef4d35bbd06), SchnorrNonce(ab2ed6246b263a8c8884c257a15920419a2a9e08258fe46267d7e4cfe9e79abc), SchnorrNonce(dfdf9e30ecd17f74b8d77467848d21663ceb2388b2595ea5553cc4bded3b0da0), SchnorrNonce(f03c54b212fb3fe9b1db4506446d1330accddd54118b29e73978d7455fb7bfb2)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy))), NumericSingleOracleInfo(OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(bf84a4c67814fbce3e4a0aae6aefa02e5c980290c8824425539581fc8f3af998),FieldElement(3ed4bae11feb46e7549a7a2fcf1d162485030a38a0524680263917a3d5ab57d4),None),SchnorrPublicKey(c3d625c28ba58cbbc90470d27185a2377031c0df30ee36545aaa732241bab02c),OracleEventV0TLV(Vector(SchnorrNonce(03d96c62d8778d7ad87d1bc029b063cbea3f5ad1e3c030469cfac1724cf4b300), SchnorrNonce(052052106369bf8c4e0711f7ca33675af14cc1df1576b15dfc0edde111c033b9), SchnorrNonce(1c9f92573b11acebad777f7d9639b4d3008501796ca17aec63c3bdc0fb70a679), SchnorrNonce(1ff48a14bce0e134dfe0da94bc4a22b81d4f879cb8568b0d5464fd2f0c311e40), SchnorrNonce(3440da9773b1d0dd
<span class="hljs-keyword">val</span> outcome = <span class="hljs-type">NumericOracleOutcome</span>(signingOracles.map((_, <span class="hljs-type">UnsignedNumericOutcome</span>(<span class="hljs-type">Vector</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>)))))
<span class="hljs-comment">// outcome: NumericOracleOutcome = NumericOracleOutcome(Vector((NumericSingleOracleInfo(OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(14de721d7a6f555422b193edf5b1b6841a75fe3b51a486167eb74e983fa569af),FieldElement(11a43b2aa21267719f3bd5023342a3c8d06fed925eeaef4860a9e78585e66b7c),None),SchnorrPublicKey(e0dfdb6a938b5a601cd3b9e136d44ee1920b413c046dffbc6caaeab7a5e27fa9),OracleEventV0TLV(Vector(SchnorrNonce(02a73ac3e319f1215bca55e13692a3e36e64c15a7398a9aec1974976ca2b8e26), SchnorrNonce(1a59a51b125733a7f9ef3b5b26132919f760f5b727df2494be0f6fbd4347345f), SchnorrNonce(1d5be13e4ec6a1b9c1a07253a6118e76607676b9bdf4e971ad714583a737b0d5), SchnorrNonce(2ea107571158bd39cf5a210db462eddc2b765fed847bc6c02e70aadb8a622143), SchnorrNonce(5753ba966d45bf335b817733792a9105ac117faea015dafdee87912609766813), SchnorrNonce(82646a833ce8ae6e9a0dfde1b8b991c81dfc0b0b95a1e9dc184c6ee012a4e757), SchnorrNonce(99bdba3bef71066da9a50da78501cca6a79299bc937705a262a0d198e4f337bb), SchnorrNonce(af5d0c190200836e96ce95ab1241222934f9cf6f3ca6e8d608cbec3479b3de71), SchnorrNonce(b2cf5bf8c8de900e39f5a85d565656e373134e6545e9517c2869bf7d52532363), SchnorrNonce(ca39f5a5ff5194353ce507335c5f3be26c9cac0d3676d81866d89c12be099106), SchnorrNonce(cb86b6935365b39e86714ea7088aa0d42cf2bab32bff61b6958462c60f0d040c), SchnorrNonce(d950120c3100154d3347ab7b873f481b556eed93b2552a6654aa923aeeef6616), SchnorrNonce(daf054cf409639e744374fbe10817b63f63cd7d89b23f8126442294dc184ffef), SchnorrNonce(e7380a827fe985b98fe2c2af7bed45cf31fc8162a759d867b0a2fbc202dab918), SchnorrNonce(ec61e5dc505927f91e7fab6e6f82b1dd5fc93e13dd1a69e443b96ca2ff569124)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy))),UnsignedNumericOutcome(Vector(0, 0, 0, 0, 0))), (NumericSingleOracleInfo(OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(93dcef6ffa39b6d39df9ee37a8444bbe047aaf57c58770ec2b8c66b98e4db175),FieldElement(e4341dfdb1641a595a15d8e56012b6222c6b482c656926a27f9a8530d003342a),None),SchnorrPublicKey(8bcc9eb03dac6ce99c5f975423bd429262c03c265a0aa4360b3d85cfb1d050b6),OracleEventV0TLV(Vector(SchnorrNonce(04c602dcef23d87555ce01297e0885d17e8bcbbf6c052cfac600c66266969b1c), SchnorrNonce(153f9fdbad465103ee12062304d38020385c97d78cc11de1aa248ddecae9ce64), SchnorrNonce(25fc644073ba7dab06b547597403cf2396d5a79dedbe7055b5065933dd5c97be), SchnorrNonce(280efe4724c3ab0bbf88ff6c95511abfee3606f281f8679faeef905b809a9979), SchnorrNonce(4d433d7b041cdad542a9c8b3a6d2f30d7b4083d7d6dfedcc859c0449f21dd2d1), SchnorrNonce(51a1ff702993b3a4b438b9fbcc914f6f68835694521b542055e5a345d44c03f0), SchnorrNonce(562cc6f949110a1338a78ce60b90ab09929590bc5f8ebe03e3e1276f49dccb10), SchnorrNonce(6247fa183f1790e8b4176c7e44ba51c1fde8b3c70b5db2dbda9b3e27a0e2e95d), SchnorrNonce(9236f068cb7ee129c341e79b6b712ff749e7b0036cf26ed653129cef4846bdbd), SchnorrNonce(9dbd80bd38c0d625a9a81a02f8132c2bfea49bf39e1b998d66320bf54cefb16c), SchnorrNonce(9efb3fa9b636122f0d55e5a47c96cd0c0c1c3636ed1e9ad386643fce81dd43f7), SchnorrNonce(9fa1679870dd854ceec0e2c00336fc63053aeaf2dee7346d7d4b3ef4d35bbd06), SchnorrNonce(ab2ed6246b263a8c8884c257a15920419a2a9e08258fe46267d7e4cfe9e79abc), SchnorrNonce(dfdf9e30ecd17f74b8d77467848d21663ceb2388b2595ea5553cc4bded3b0da0), SchnorrNonce(f03c54b212fb3fe9b1db4506446d1330accddd54118b29e73978d7455fb7bfb2)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy))),UnsignedNumericOutcome(Vector(0, 0, 0, 0, 0))), (NumericSingleOracleInfo(OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(bf84a4c67814fbce3e4a0aae6aefa02e5c980290c8824425539581fc8f3af998),FieldElement(3ed4bae11feb46e7549a7a2fcf1d162485030a38a0524680263917a3d5ab57d4),None),SchnorrPublicKey(c3d625c28ba58cbbc90470d27185a2377031c0df30ee36545aaa732241bab02c),OracleEventV0TLV(Vector(SchnorrNonce(03d96c62d8778d7ad87d1bc029b063cbea3f5ad1e3c030469cfac1724cf4b300), SchnorrNonce(052052106369bf8c4e0711f7ca33675af14cc1df1576b15dfc0edde111c033b9), SchnorrNonce(1c9f92573b11acebad777f7d9639b4d3008501796ca17aec63c3bdc0fb70a679), SchnorrNo
contractInfo.getPayouts(outcome)
<span class="hljs-comment">// res15: (Satoshis, Satoshis) = (0 sats,1000 sats)</span>
</code></pre>
<h2><a class="anchor" aria-hidden="true" id="tlv"></a><a href="#tlv" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>TLV</h2>
<p><a href="https://github.com/bitcoin-s/bitcoin-s/blob/master/core/src/main/scala/org/bitcoins/core/protocol/tlv/TLV.scala">TLV.scala</a> provides protocol agnostic infrastructure for the Type-Length-Value (TLV) serialization format which is used by both the Lightning Network and DLCs. The file contains a sealed trait of all possible TLVs as well as utilities for defining new types.</p>
<p>This includes <code>NormalizedString</code> a standardized string serialization using varint-prefixed UTF-8 with NFC normalization which has implicit conversions with <code>String</code> so that they can be used interchangeably. This also includes a <code>TLVUtil</code> trait for serialization and a <code>ValueIterator</code> class for deserialization.</p>
<p>Currently, only the most basic Lightning messages are defined (<code>Ping</code>, <code>Pong</code>, <code>Error</code>) but all DLC messages are supported.</p>
<h2><a class="anchor" aria-hidden="true" id="lnmessage"></a><a href="#lnmessage" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>LnMessage</h2>
<p><a href="https://github.com/bitcoin-s/bitcoin-s/blob/master/core/src/main/scala/org/bitcoins/core/protocol/tlv/LnMessage.scala">LnMessage.scala</a> provides support for the Lightning Network Message serialization format, which is very similar to the <a href="#tlv">TLV</a> format with some minor differences so that an <code>LnMessage</code> simply wraps a <code>TLV</code> and provides the altered serialization format. Likewise one can parse a <code>LnMessage</code> using a <code>TLVFactory</code> and subsequently unwrap to get the nested <code>TLV</code>.</p>
<pre><code class="hljs css language-scala"><span class="hljs-keyword">val</span> offerTLV = <span class="hljs-type">DLCOfferTLV</span>(
protocolVersionOpt = <span class="hljs-type">None</span>,
contractFlags = <span class="hljs-number">0.</span>toByte,
chainHash = <span class="hljs-type">DoubleSha256Digest</span>.empty,
contractInfo = contractInfo.toTLV,
fundingPubKey = <span class="hljs-type">ECPublicKey</span>.freshPublicKey,
payoutSPK = <span class="hljs-type">EmptyScriptPubKey</span>,
payoutSerialId = <span class="hljs-type">UInt64</span>(<span class="hljs-number">1</span>),
offererCollateralSatoshis = <span class="hljs-type">Satoshis</span>(<span class="hljs-number">500</span>),
fundingInputs = <span class="hljs-type">Vector</span>(<span class="hljs-type">FundingInputV0TLV</span>.dummy),
changeSPK = <span class="hljs-type">EmptyScriptPubKey</span>,
changeSerialId = <span class="hljs-type">UInt64</span>(<span class="hljs-number">2</span>),
fundOutputSerialId = <span class="hljs-type">UInt64</span>(<span class="hljs-number">3</span>),
feeRate = <span class="hljs-type">SatoshisPerVirtualByte</span>(<span class="hljs-type">Satoshis</span>(<span class="hljs-number">1</span>)),
contractMaturityBound = <span class="hljs-type">BlockStamp</span>.<span class="hljs-type">BlockHeight</span>(<span class="hljs-number">0</span>),
contractTimeout = <span class="hljs-type">BlockStamp</span>.<span class="hljs-type">BlockHeight</span>(<span class="hljs-number">0</span>)
)
<span class="hljs-comment">// offerTLV: DLCOfferTLV = DLCOfferTLV(None,0,DoubleSha256Digest(0000000000000000000000000000000000000000000000000000000000000000),ContractInfoV0TLV(1000 sats,ContractDescriptorV1TLV(15,PayoutFunctionV0TLV(IndexedSeq(TLVPoint(0,0 sats,0), TLVPoint(1000,0 sats,0), TLVPoint(2000,1000 sats,0), TLVPoint(32767,1000 sats,0)),Vector(PolynomialPayoutCurvePieceTLV(Vector()), PolynomialPayoutCurvePieceTLV(Vector()), PolynomialPayoutCurvePieceTLV(Vector())),Beta),RoundingIntervalsV0TLV(Vector((0,100 sats)))),OracleInfoV2TLV(3,IndexedSeq(OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(14de721d7a6f555422b193edf5b1b6841a75fe3b51a486167eb74e983fa569af),FieldElement(11a43b2aa21267719f3bd5023342a3c8d06fed925eeaef4860a9e78585e66b7c),None),SchnorrPublicKey(e0dfdb6a938b5a601cd3b9e136d44ee1920b413c046dffbc6caaeab7a5e27fa9),OracleEventV0TLV(Vector(SchnorrNonce(02a73ac3e319f1215bca55e13692a3e36e64c15a7398a9aec1974976ca2b8e26), SchnorrNonce(1a59a51b125733a7f9ef3b5b26132919f760f5b727df2494be0f6fbd4347345f), SchnorrNonce(1d5be13e4ec6a1b9c1a07253a6118e76607676b9bdf4e971ad714583a737b0d5), SchnorrNonce(2ea107571158bd39cf5a210db462eddc2b765fed847bc6c02e70aadb8a622143), SchnorrNonce(5753ba966d45bf335b817733792a9105ac117faea015dafdee87912609766813), SchnorrNonce(82646a833ce8ae6e9a0dfde1b8b991c81dfc0b0b95a1e9dc184c6ee012a4e757), SchnorrNonce(99bdba3bef71066da9a50da78501cca6a79299bc937705a262a0d198e4f337bb), SchnorrNonce(af5d0c190200836e96ce95ab1241222934f9cf6f3ca6e8d608cbec3479b3de71), SchnorrNonce(b2cf5bf8c8de900e39f5a85d565656e373134e6545e9517c2869bf7d52532363), SchnorrNonce(ca39f5a5ff5194353ce507335c5f3be26c9cac0d3676d81866d89c12be099106), SchnorrNonce(cb86b6935365b39e86714ea7088aa0d42cf2bab32bff61b6958462c60f0d040c), SchnorrNonce(d950120c3100154d3347ab7b873f481b556eed93b2552a6654aa923aeeef6616), SchnorrNonce(daf054cf409639e744374fbe10817b63f63cd7d89b23f8126442294dc184ffef), SchnorrNonce(e7380a827fe985b98fe2c2af7bed45cf31fc8162a759d867b0a2fbc202dab918), SchnorrNonce(ec61e5dc505927f91e7fab6e6f82b1dd5fc93e13dd1a69e443b96ca2ff569124)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy)), OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(93dcef6ffa39b6d39df9ee37a8444bbe047aaf57c58770ec2b8c66b98e4db175),FieldElement(e4341dfdb1641a595a15d8e56012b6222c6b482c656926a27f9a8530d003342a),None),SchnorrPublicKey(8bcc9eb03dac6ce99c5f975423bd429262c03c265a0aa4360b3d85cfb1d050b6),OracleEventV0TLV(Vector(SchnorrNonce(04c602dcef23d87555ce01297e0885d17e8bcbbf6c052cfac600c66266969b1c), SchnorrNonce(153f9fdbad465103ee12062304d38020385c97d78cc11de1aa248ddecae9ce64), SchnorrNonce(25fc644073ba7dab06b547597403cf2396d5a79dedbe7055b5065933dd5c97be), SchnorrNonce(280efe4724c3ab0bbf88ff6c95511abfee3606f281f8679faeef905b809a9979), SchnorrNonce(4d433d7b041cdad542a9c8b3a6d2f30d7b4083d7d6dfedcc859c0449f21dd2d1), SchnorrNonce(51a1ff702993b3a4b438b9fbcc914f6f68835694521b542055e5a345d44c03f0), SchnorrNonce(562cc6f949110a1338a78ce60b90ab09929590bc5f8ebe03e3e1276f49dccb10), SchnorrNonce(6247fa183f1790e8b4176c7e44ba51c1fde8b3c70b5db2dbda9b3e27a0e2e95d), SchnorrNonce(9236f068cb7ee129c341e79b6b712ff749e7b0036cf26ed653129cef4846bdbd), SchnorrNonce(9dbd80bd38c0d625a9a81a02f8132c2bfea49bf39e1b998d66320bf54cefb16c), SchnorrNonce(9efb3fa9b636122f0d55e5a47c96cd0c0c1c3636ed1e9ad386643fce81dd43f7), SchnorrNonce(9fa1679870dd854ceec0e2c00336fc63053aeaf2dee7346d7d4b3ef4d35bbd06), SchnorrNonce(ab2ed6246b263a8c8884c257a15920419a2a9e08258fe46267d7e4cfe9e79abc), SchnorrNonce(dfdf9e30ecd17f74b8d77467848d21663ceb2388b2595ea5553cc4bded3b0da0), SchnorrNonce(f03c54b212fb3fe9b1db4506446d1330accddd54118b29e73978d7455fb7bfb2)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy)), OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(bf84a4c67814fbce3e4a0aae6aefa02e5c980290c8824425539581fc8f3af998),FieldElement(3ed4bae11feb46e7549a7a2fcf1d162485030a38a0524680263917a3d5ab57d4),None),SchnorrPublicKey(c3d625c28ba58cbbc90470d27185a2377031c0df3
<span class="hljs-keyword">val</span> lnMsgHex = <span class="hljs-type">LnMessage</span>(offerTLV).hex
<span class="hljs-comment">// lnMsgHex: String = a71a000000000000000000000000000000000000000000000000000000000000000000fdd82efd0c7200000000000003e8fda7203c000ffda7262e000300000000fda728020000fd03e8000000fda728020000fd07d0fd03e80000fda728020000fd7ffffd03e80000fda7240400010064fdd82cfd0c2400030005fdd824fd026514de721d7a6f555422b193edf5b1b6841a75fe3b51a486167eb74e983fa569af11a43b2aa21267719f3bd5023342a3c8d06fed925eeaef4860a9e78585e66b7ce0dfdb6a938b5a601cd3b9e136d44ee1920b413c046dffbc6caaeab7a5e27fa9fdd822fd01ff000f02a73ac3e319f1215bca55e13692a3e36e64c15a7398a9aec1974976ca2b8e261a59a51b125733a7f9ef3b5b26132919f760f5b727df2494be0f6fbd4347345f1d5be13e4ec6a1b9c1a07253a6118e76607676b9bdf4e971ad714583a737b0d52ea107571158bd39cf5a210db462eddc2b765fed847bc6c02e70aadb8a6221435753ba966d45bf335b817733792a9105ac117faea015dafdee8791260976681382646a833ce8ae6e9a0dfde1b8b991c81dfc0b0b95a1e9dc184c6ee012a4e75799bdba3bef71066da9a50da78501cca6a79299bc937705a262a0d198e4f337bbaf5d0c190200836e96ce95ab1241222934f9cf6f3ca6e8d608cbec3479b3de71b2cf5bf8c8de900e39f5a85d565656e373134e6545e9517c2869bf7d52532363ca39f5a5ff5194353ce507335c5f3be26c9cac0d3676d81866d89c12be099106cb86b6935365b39e86714ea7088aa0d42cf2bab32bff61b6958462c60f0d040cd950120c3100154d3347ab7b873f481b556eed93b2552a6654aa923aeeef6616daf054cf409639e744374fbe10817b63f63cd7d89b23f8126442294dc184ffefe7380a827fe985b98fe2c2af7bed45cf31fc8162a759d867b0a2fbc202dab918ec61e5dc505927f91e7fab6e6f82b1dd5fc93e13dd1a69e443b96ca2ff56912400000000fdd80a0f0002000564756d6d7900000000000f0564756d6d79fdd824fd026593dcef6ffa39b6d39df9ee37a8444bbe047aaf57c58770ec2b8c66b98e4db175e4341dfdb1641a595a15d8e56012b6222c6b482c656926a27f9a8530d003342a8bcc9eb03dac6ce99c5f975423bd429262c03c265a0aa4360b3d85cfb1d050b6fdd822fd01ff000f04c602dcef23d87555ce01297e0885d17e8bcbbf6c052cfac600c66266969b1c153f9fdbad465103ee12062304d38020385c97d78cc11de1aa248ddecae9ce6425fc644073ba7dab06b547597403cf2396d5a79dedbe7055b5065933dd5c97be280efe4724c3ab0bbf88ff6c95511abfee3606f281f8679faeef905b809a99794d433d7b041cdad542a9c8b3a6d2f30d7b4083d7d6dfedcc859c0449f21dd2d151a1ff702993b3a4b438b9fbcc914f6f68835694521b542055e5a345d44c03f0562cc6f949110a1338a78ce60b90ab09929590bc5f8ebe03e3e1276f49dccb106247fa183f1790e8b4176c7e44ba51c1fde8b3c70b5db2dbda9b3e27a0e2e95d9236f068cb7ee129c341e79b6b712ff749e7b0036cf26ed653129cef4846bdbd9dbd80bd38c0d625a9a81a02f8132c2bfea49bf39e1b998d66320bf54cefb16c9efb3fa9b636122f0d55e5a47c96cd0c0c1c3636ed1e9ad386643fce81dd43f79fa1679870dd854ceec0e2c00336fc63053aeaf2dee7346d7d4b3ef4d35bbd06ab2ed6246b263a8c8884c257a15920419a2a9e08258fe46267d7e4cfe9e79abcdfdf9e30ecd17f74b8d77467848d21663ceb2388b2595ea5553cc4bded3b0da0f03c54b212fb3fe9b1db4506446d1330accddd54118b29e73978d7455fb7bfb200000000fdd80a0f0002000564756d6d7900000000000f0564756d6d79fdd824fd0265bf84a4c67814fbce3e4a0aae6aefa02e5c980290c8824425539581fc8f3af9983ed4bae11feb46e7549a7a2fcf1d162485030a38a0524680263917a3d5ab57d4c3d625c28ba58cbbc90470d27185a2377031c0df30ee36545aaa732241bab02cfdd822fd01ff000f03d96c62d8778d7ad87d1bc029b063cbea3f5ad1e3c030469cfac1724cf4b300052052106369bf8c4e0711f7ca33675af14cc1df1576b15dfc0edde111c033b91c9f92573b11acebad777f7d9639b4d3008501796ca17aec63c3bdc0fb70a6791ff48a14bce0e134dfe0da94bc4a22b81d4f879cb8568b0d5464fd2f0c311e403440da9773b1d0dd9f6b18632e420c92da72c95551ed7dfb8f3c1d21f63f9cc451f67cb829e24d29f00ab28e88025fa4fa24d258d24c9bca994f6ddd2ecdc3ec8816c2ac00e75495e3ffc19ca6fa1ea39431590f420b73e91d37aaad7eb9e8fb8a3f2b4e20611b4a9583bf64bab970ddb8c130eb65c850b3ed9941f303656363988398a518cf1feb512e824f05496047302270c3ce0651319c23773290ae768ab421df43f4f140125166710ad78590d1e176e0a243fc97b7a93fceebaef93910c35c9a455e7aa14859b6d12a24448564e6f0c3b42db804155c88ea4cf9e6686dd74414bbb4225e723295725dc7e6b904d804f4e84dcf00fc507cc697d2b277bfda6c94fcba40096855bbf35c02adbf0a0622238cfad6ae27fd84f11d6f0f8a9eeb04d3d57fccc82e360e4f4e95adc02e25b0fe885f1e93f8be19dd4b27e6e401fe2919884ed5594dda92b40cc2369256fbfef428a09f65e9da4594809a5eb38400000000fdd80a0f0002000564756d6d7900000000000f0564756d6d79fdd824fd0265da5752e0296a01a218ebebdfbd57aabeda665342409feca06ef46f27d011b6f7ac059f1dda
<span class="hljs-keyword">val</span> lnMsg = <span class="hljs-type">LnMessageFactory</span>(<span class="hljs-type">DLCOfferTLV</span>).fromHex(lnMsgHex)
<span class="hljs-comment">// lnMsg: LnMessage[DLCOfferTLV] = LnMessage(DLCOfferTLV(None,0,DoubleSha256Digest(0000000000000000000000000000000000000000000000000000000000000000),ContractInfoV0TLV(1000 sats,ContractDescriptorV1TLV(15,PayoutFunctionV0TLV(IndexedSeq(TLVPoint(0,0 sats,0), TLVPoint(1000,0 sats,0), TLVPoint(2000,1000 sats,0), TLVPoint(32767,1000 sats,0)),Vector(PolynomialPayoutCurvePieceTLV(Vector()), PolynomialPayoutCurvePieceTLV(Vector()), PolynomialPayoutCurvePieceTLV(Vector())),Beta),RoundingIntervalsV0TLV(Vector((0,100 sats)))),OracleInfoV2TLV(3,IndexedSeq(OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(14de721d7a6f555422b193edf5b1b6841a75fe3b51a486167eb74e983fa569af),FieldElement(11a43b2aa21267719f3bd5023342a3c8d06fed925eeaef4860a9e78585e66b7c),None),SchnorrPublicKey(e0dfdb6a938b5a601cd3b9e136d44ee1920b413c046dffbc6caaeab7a5e27fa9),OracleEventV0TLV(Vector(SchnorrNonce(02a73ac3e319f1215bca55e13692a3e36e64c15a7398a9aec1974976ca2b8e26), SchnorrNonce(1a59a51b125733a7f9ef3b5b26132919f760f5b727df2494be0f6fbd4347345f), SchnorrNonce(1d5be13e4ec6a1b9c1a07253a6118e76607676b9bdf4e971ad714583a737b0d5), SchnorrNonce(2ea107571158bd39cf5a210db462eddc2b765fed847bc6c02e70aadb8a622143), SchnorrNonce(5753ba966d45bf335b817733792a9105ac117faea015dafdee87912609766813), SchnorrNonce(82646a833ce8ae6e9a0dfde1b8b991c81dfc0b0b95a1e9dc184c6ee012a4e757), SchnorrNonce(99bdba3bef71066da9a50da78501cca6a79299bc937705a262a0d198e4f337bb), SchnorrNonce(af5d0c190200836e96ce95ab1241222934f9cf6f3ca6e8d608cbec3479b3de71), SchnorrNonce(b2cf5bf8c8de900e39f5a85d565656e373134e6545e9517c2869bf7d52532363), SchnorrNonce(ca39f5a5ff5194353ce507335c5f3be26c9cac0d3676d81866d89c12be099106), SchnorrNonce(cb86b6935365b39e86714ea7088aa0d42cf2bab32bff61b6958462c60f0d040c), SchnorrNonce(d950120c3100154d3347ab7b873f481b556eed93b2552a6654aa923aeeef6616), SchnorrNonce(daf054cf409639e744374fbe10817b63f63cd7d89b23f8126442294dc184ffef), SchnorrNonce(e7380a827fe985b98fe2c2af7bed45cf31fc8162a759d867b0a2fbc202dab918), SchnorrNonce(ec61e5dc505927f91e7fab6e6f82b1dd5fc93e13dd1a69e443b96ca2ff569124)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy)), OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(93dcef6ffa39b6d39df9ee37a8444bbe047aaf57c58770ec2b8c66b98e4db175),FieldElement(e4341dfdb1641a595a15d8e56012b6222c6b482c656926a27f9a8530d003342a),None),SchnorrPublicKey(8bcc9eb03dac6ce99c5f975423bd429262c03c265a0aa4360b3d85cfb1d050b6),OracleEventV0TLV(Vector(SchnorrNonce(04c602dcef23d87555ce01297e0885d17e8bcbbf6c052cfac600c66266969b1c), SchnorrNonce(153f9fdbad465103ee12062304d38020385c97d78cc11de1aa248ddecae9ce64), SchnorrNonce(25fc644073ba7dab06b547597403cf2396d5a79dedbe7055b5065933dd5c97be), SchnorrNonce(280efe4724c3ab0bbf88ff6c95511abfee3606f281f8679faeef905b809a9979), SchnorrNonce(4d433d7b041cdad542a9c8b3a6d2f30d7b4083d7d6dfedcc859c0449f21dd2d1), SchnorrNonce(51a1ff702993b3a4b438b9fbcc914f6f68835694521b542055e5a345d44c03f0), SchnorrNonce(562cc6f949110a1338a78ce60b90ab09929590bc5f8ebe03e3e1276f49dccb10), SchnorrNonce(6247fa183f1790e8b4176c7e44ba51c1fde8b3c70b5db2dbda9b3e27a0e2e95d), SchnorrNonce(9236f068cb7ee129c341e79b6b712ff749e7b0036cf26ed653129cef4846bdbd), SchnorrNonce(9dbd80bd38c0d625a9a81a02f8132c2bfea49bf39e1b998d66320bf54cefb16c), SchnorrNonce(9efb3fa9b636122f0d55e5a47c96cd0c0c1c3636ed1e9ad386643fce81dd43f7), SchnorrNonce(9fa1679870dd854ceec0e2c00336fc63053aeaf2dee7346d7d4b3ef4d35bbd06), SchnorrNonce(ab2ed6246b263a8c8884c257a15920419a2a9e08258fe46267d7e4cfe9e79abc), SchnorrNonce(dfdf9e30ecd17f74b8d77467848d21663ceb2388b2595ea5553cc4bded3b0da0), SchnorrNonce(f03c54b212fb3fe9b1db4506446d1330accddd54118b29e73978d7455fb7bfb2)),UInt32Impl(0),UnsignedDigitDecompositionEventDescriptor(UInt16Impl(2),UInt16Impl(15),dummy,Int32Impl(0)),dummy)), OracleAnnouncementV0TLV(SchnorrDigitalSignature(SchnorrNonce(bf84a4c67814fbce3e4a0aae6aefa02e5c980290c8824425539581fc8f3af998),FieldElement(3ed4bae11feb46e7549a7a2fcf1d162485030a38a0524680263917a3d5ab57d4),None),SchnorrPublicKey(c3d625c28ba58cbbc90470d
lnMsg.tlv == offerTLV
<span class="hljs-comment">// res16: Boolean = false</span>
</code></pre>
</span></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/next/core/psbts"><span class="arrow-prev"></span><span>Partially Signed Bitcoin Transactions</span></a><a class="docs-next button" href="/docs/next/core/txbuilder"><span class="function-name-prevnext">TxBuilder Example</span><span class="arrow-next"></span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#dlcpayoutcurve">DLCPayoutCurve</a></li><li><a href="#cetcalculator">CETCalculator</a></li><li><a href="#oracleoutcome">OracleOutcome</a></li><li><a href="#dlcstatus">DLCStatus</a></li><li><a href="#contractinfo">ContractInfo</a></li><li><a href="#tlv">TLV</a></li><li><a href="#lnmessage">LnMessage</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/favicon.ico" alt="bitcoin-s" width="66" height="58"/></a><div><h5>Docs</h5><a href="/docs/en/getting-started">Getting Started</a><a href="/docs/en/core/core-intro">Guides</a><a href="/api/org/bitcoins">API Reference</a></div><div><h5>Community</h5><a href="/en/users.html">User Showcase</a><a href="https://join.slack.com/t/suredbits/shared_invite/zt-eavycu0x-WQL7XOakzQo8tAy7jHHZUw" target="_blank" rel="noreferrer noopener">Slack</a><a href="https://gitter.im/bitcoin-s-core/">Gitter chat</a></div><div><h5>More</h5><a href="https://github.com/bitcoin-s/bitcoin-s">GitHub</a><a class="github-button" href="https://github.com/bitcoin-s/bitcoin-s" data-icon="octicon-star" data-count-href="/bitcoin-s/bitcoin-s-core/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">Star</a></div></section><section class="copyright">Copyright © 2025 Suredbits &amp; the bitcoin-s developers</section></footer></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script><script>
document.addEventListener('keyup', function(e) {
if (e.target !== document.body) {
return;
}
// keyCode for '/' (slash)
if (e.keyCode === 191) {
const search = document.getElementById('search_input_react');
search && search.focus();
}
});
</script><script>
var search = docsearch({
apiKey: '0a510688bf8448e19aeb380377d328d3',
indexName: 'bitcoin-s',
inputSelector: '#search_input_react'
});
</script></body></html>