@@ -160,18 +160,23 @@ export class RuneUpdater implements RuneBlockIndex {
160160 . filter ( ( [ _ , vout ] ) => ! isScriptPubKeyHexOpReturn ( vout . scriptPubKey . hex ) )
161161 . map ( ( [ index ] ) => index ) ;
162162
163- if ( amount === 0n ) {
164- // if amount is zero, divide balance between eligible outputs
165- const amount = u128 ( u128 ( maybeBalance . amount ) / u128 ( destinations . length ) ) ;
166- const remainder = u128 ( maybeBalance . amount ) % u128 ( destinations . length ) ;
167-
168- for ( const [ i , output ] of destinations . entries ( ) ) {
169- allocate ( i < remainder ? u128 . checkedAddThrow ( amount , u128 ( 1 ) ) : amount , output ) ;
170- }
171- } else {
172- // if amount is non-zero, distribute amount to eligible outputs
173- for ( const output of destinations ) {
174- allocate ( amount < maybeBalance . amount ? amount : u128 ( maybeBalance . amount ) , output ) ;
163+ if ( destinations . length !== 0 ) {
164+ if ( amount === 0n ) {
165+ // if amount is zero, divide balance between eligible outputs
166+ const amount = u128 ( u128 ( maybeBalance . amount ) / u128 ( destinations . length ) ) ;
167+ const remainder = u128 ( maybeBalance . amount ) % u128 ( destinations . length ) ;
168+
169+ for ( const [ i , output ] of destinations . entries ( ) ) {
170+ allocate ( i < remainder ? u128 . checkedAddThrow ( amount , u128 ( 1 ) ) : amount , output ) ;
171+ }
172+ } else {
173+ // if amount is non-zero, distribute amount to eligible outputs
174+ for ( const output of destinations ) {
175+ allocate (
176+ amount < maybeBalance . amount ? amount : u128 ( maybeBalance . amount ) ,
177+ output
178+ ) ;
179+ }
175180 }
176181 }
177182 } else {
0 commit comments