From 3e5d2fe86a91048ebbf473b63d9f6a9af379ea39 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 21 Feb 2016 17:52:08 +0800 Subject: [PATCH] Add CScript::PushWithdraw function --- src/script/script.cpp | 14 ++++++++++++++ src/script/script.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/script/script.cpp b/src/script/script.cpp index 3392615084..6c141e26ad 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -336,6 +336,20 @@ COutPoint CScript::GetWithdrawSpent() const } } +void CScript::PushWithdraw(const vector push) { + int64_t pushCount = 0; + for (vector::const_iterator it = push.begin(); it < push.end(); pushCount++) { + if (push.end() - it < 520) { + *this << vector(it, push.end()); + it = push.end(); + } else { + *this << vector(it, it + 520); + it += 520; + } + } + *this << pushCount; +} + bool CScript::IsPayToScriptHash() const { // Extra-fast test for pay-to-script-hash CScripts: diff --git a/src/script/script.h b/src/script/script.h index 087ac4ea4f..1d2046b6d7 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -635,6 +635,9 @@ public: /** Returns true if this is a proof-of-withdraw, spending an IsWithdrawLock */ bool IsWithdrawProof() const; + //! Push a vector with a length postfix (as used by withdraw proofs) + void PushWithdraw(const std::vector push); + /** Get the withdraw output spent, asserting IsWithdrawProof first */ COutPoint GetWithdrawSpent() const;